1

Using the Oats data from the nlme package, I wish to add the individual block names (I to VI) to the plot below.

I've read Add labels on lattice xyplot but I still don't quite understand it well and it doesn't answer my question.

Here's the code for the plot:

library(nlme)

xyplot(yield~nitro, data = Oats, groups=Block, type="l", main = "Oats data")

I just wanted to add that my original data has more than 20 Ids (unlike the Oats data which only has 6).

Thanks

Community
  • 1
  • 1
John_dydx
  • 951
  • 1
  • 14
  • 27
  • May be this helps, if you want to add legend `xyplot(yield~nitro, data = Oats, groups=Block, type="l", main = "Oats data", auto.key=list(title="Block", corner=c(0.95, 1), cex=1.0))` – akrun Sep 09 '14 at 12:07
  • @akrun, thanks for your answer. The legend works well when there are few ids as in the Oats data (only 6). The actual dataset I'm working with has more ids (about 26) which means there'll be an overlap of colours for each plot. – John_dydx Sep 09 '14 at 12:18
  • You could check `RColorBrewer` and also `http://stackoverflow.com/questions/6181653/creating-a-more-continuous-color-palette-in-r-ggplot2-lattice-or-latticeextra` which is not exactly the one you asked. I am a bit busy now. – akrun Sep 09 '14 at 12:36
  • thanks, I'll check those out. – John_dydx Sep 09 '14 at 12:40

0 Answers0