[R] Auto key legend does not match plot

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Aug 23 06:30:16 CEST 2011


On Sat, Aug 20, 2011 at 3:53 AM, markm0705 <markm0705 at gmail.com> wrote:
> Dear R-help members.  I am an 'R-learner' (about 6 hours so far) using the
> lattice library to create a ranked dotplot and am colour coding the dots by
> a variable called "Commodity".  However when i use autokey to make a legend
> the size (cex) and symbol (pch) do not match what is on the dotplot.
> Code is below and image attached
>
> library("lattice")
> Cal_dat <- read.table("Calibration2.dat",header = TRUE,sep = "\t",)
> dotplot(reorder(Label.yr, Resc_Gt)~ Resc_Gt,groups=Commodity,
>        data=Cal_dat,cex=1.5, pch=19,aspect="xy",
>        auto.key=list(space="right",title="Commodity"))

Try

dotplot(reorder(Label.yr, Resc_Gt)~ Resc_Gt,groups=Commodity,
       data=Cal_dat,
       par.settings = simpleTheme(cex=1.5, pch=19),
       aspect="xy",
       auto.key=list(space="right",title="Commodity"))

(see ?simpleTheme for an explanation).

-Deepayan



More information about the R-help mailing list