[R] Missing text in lattice key legend

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Mon Oct 11 14:38:36 CEST 2021


Awesome, thanks!

On Mon, Oct 11, 2021 at 2:19 PM Deepayan Sarkar
<deepayan.sarkar using gmail.com> wrote:
>
> On Mon, Oct 11, 2021 at 5:17 PM Luigi Marongiu <marongiu.luigi using gmail.com> wrote:
> >
> > Hello,
> > I am drawing some data with lattice using:
> > ```
> > library(lattice)
> > COLS = c("gold", "forestgreen", "darkslategray3", "purple")
> > xyplot(Value ~ Concentration,
> >        group = Substance, data = inf_avg,
> >        pch = 16, cex = 1.2, type = "b",
> >        xlab=expression(bold(paste("Concentration (", mu, "M)"))),
> >        ylab=expression(bold("Infection rate")),
> >        col=COLS,
> >        scales = list(x = list(log = 10, at=c(unique(inf_avg$Concentration))
> >                               )
> >                      ),
> >        key = list(space="top", columns=4, col = "black",
> >                        points=list(pch=c(16, 16, 16, 16),
> >                                    col=COLS,
> >                                    text=list(c("6-PN", "8-PN", "IX", "XN")
> >                                             )
> >                                    )
> >                   ),
> >        panel = function(x,y) {
> >          panel.xyplot(x,y)
> >          errbar()
> >        }
> > )
> > ```
> > It all works but the legend only shows the colored dots, there is no
> > text. Is it something missing from the syntax?
>
> Your text component is nested inside the points component. I think you
> want it outside, e.g.,
>
> xyplot(1 ~ 1,
>        key = list(space="top", columns=4, col = "black",
>                   points=list(pch=c(16, 16, 16, 16),
>                               col=COLS),
>                   text=list(c("6-PN", "8-PN", "IX", "XN"))
>                   ))
>
> Best,
> -Deepayan
>
> > Thanks
> >
> > --
> > Best regards,
> > Luigi
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.



-- 
Best regards,
Luigi



More information about the R-help mailing list