[R] Plotting Multiple Factors By Dates With Lattice
Rich Shepard
rshepard at appl-ecosys.com
Fri Aug 16 16:49:21 CEST 2013
On Thu, 15 Aug 2013, Rich Shepard wrote:
> Now I see the source of my error: I quoted the data file name! Removing
> the quotation marks produces the plots.
Thanks to A.K. and Dennis Murphy I understand how to plot the data in
these data sets. However, I am not getting the colors within the plot to
match those in the key despite reading about using color pallettes and
experimenting with pallettes and various numbers of colors. Since I don't
see what I'm doing incorrectly I'd appreciate having someone point this out
to me.
Data set:
> dput(bdf)
structure(list(sampdate = structure(c(11156, 11156, 11156, 11156,
11156, 12241, 12241, 12241, 12241, 12241, 12977, 12977, 12977,
12977, 12977, 13327, 13327, 13327, 13327, 13327, 14866, 14866,
14866, 14866, 14866, 14866, 14866, 15168, 15168, 15168, 15168,
15168, 15168, 15170, 15170, 15170, 15170, 15170, 15170, 15170,
15532, 15532, 15532, 15532, 15532, 15532), class = "Date"), func_feed_grp =
structure(c(1L,
2L, 3L, 6L, 7L, 1L, 2L, 3L, 6L, 7L, 1L, 2L, 3L, 6L, 7L, 1L, 2L,
3L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 6L, 7L), .Label = c(" Filterer
",
" Gatherer ", " Grazer ", " Omnivore ", " Parasite ",
" Predator ", " Shredder "), class = "factor"), pct = c(0.0351,
0.7054, 0.0442, 0.1078, 0.1074, 0.157, 0.7039, 0.0023, 0.0456,
0.0912, 0.0293, 0.6634, 0.0055, 0.0552, 0.2466, 0.0414, 0.4776,
0.1033, 0.2012, 0.1765, 0.0811, 0.5785, 0.0284, 0.0131, 0.0018,
0.0736, 0.2234, 0.0041, 0.9011, 0.0563, 0.01, 0.0037, 0.0247,
0.0385, 0.8469, 0.0147, 5e-04, 0.0197, 0.0688, 0.0109, 0.1275,
0.503, 0.0257, 8e-04, 0.1464, 0.1966)), .Names = c("sampdate",
"func_feed_grp", "pct"), row.names = c(NA, -46L), class = "data.frame")
The command I'm using to plot this data frame:
xyplot(pct ~ sampdate, data = bdf, groups = func_feed_grp, type = 'l', col =
rainbow(8), key = simpleKey(text = levels(bdf$func_feed_grp), space =
'right'))
I've used rainbow(6) through rainbow(12) and cannont get it correct. A
sample plot is attached. Notice for the left-most points (year 2000) there
are 5 functional feeding groups in the data: gatherers (approximately 70
percent), predators and shredders (approximately 10 percent each), grazers
and scrapers (approximately 4 percent each). According to the key parasites
are approximately 70 percent of those data and gatherers approximately 10
percent. That's not correct.
Rich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.plot.pdf
Type: application/pdf
Size: 5138 bytes
Desc:
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130816/bbf0338d/attachment.pdf>
More information about the R-help
mailing list