[R] Adding a second Y axis on a dotplot

li li hannah.hlx at gmail.com
Fri Sep 11 19:30:28 CEST 2015


Hi all,
  I plotted a dotplot based on the data below and code below. I would
like to add another yaxis on the right with a different col, different
tickmarks and a different label. Can anyone give some help?Thanks very
much!!
     Hanna


> tmp1
   result  lot  trt trtsymb trtcol
1      98 lot1 trt1       1   blue
2      99 lot2 trt1       1   blue
3      98 lot3 trt1       1   blue
4     100 lot4 trt1       1   blue
5     100 lot5 trt1       1   blue
6     101 lot6 trt1       1   blue
7     101 lot7 trt1       1   blue
8      99 lot8 trt1       1   blue
9     100 lot9 trt1       1   blue
10     94 lot1 trt2      16    red
11    105 lot2 trt2      16    red
12     87 lot3 trt2      16    red
13    119 lot4 trt2      16    red
14     96 lot5 trt2      16    red
15    113 lot6 trt2      16    red
16    106 lot7 trt2      16    red
17     71 lot8 trt2      16    red
18     95 lot9 trt2      16    red


library(lattice)
dotplot(result ~ lot, tmp1, cex=1.1,  ylab = "values", xlab="lot",
jitter.y = F, aspect=1.0,
        pch=tmp1$trtsymb, col=tmp1$trtcol, scales=list(rot=30),
main="", key = list(text = list(labels = c("trt1", "trt2"),cex=c(0.9,0.9)),
points = list(pch =c(1,12), col =c("blue", "red")),
space = "right"))



More information about the R-help mailing list