Tom Roche
2012-Nov-18 14:43 UTC
[R] [lattice] how to label panels with variable value (not name)?
As described @ https://stat.ethz.ch/pipermail/r-help/2012-November/329442.html I now know how to prepare my netCDF data specifying gas concentrations over a 3D space (dimensions longitude, latitude, and (vertical) level), so as to call lattice::levelplot() like levelplot(conc ~ lon * lat | lev, data=data.frame) which labels each panel in the lattice of plots with the name "lev" plus a graphical indicator of the level value. Alternatively, I can label each panel with an index (i.e., "1", "2", ...) by calling levelplot(conc ~ lon * lat | factor(lev), data=data.frame) However I will need to before-and-after compare this to the results of a reboxing, or 3D regridding, of this data, so I would prefer instead to label each panel in the lattice with the _value_ of the level (an atmospheric pressure), rather than the name or index of the level. How to do that? TIA, Tom Roche <Tom_Roche at pobox.com>
Bert Gunter
2012-Nov-18 15:48 UTC
[R] [lattice] how to label panels with variable value (not name)?
AFAICS, you will have to pre-compute the values and create a factor with levels these values as character strings. Then use this factor as the conditioning variable ?sprintf ?formatC ?round and the like may be useful to format the numerical values suitably for your labels. Cheers, Bert On Sun, Nov 18, 2012 at 6:43 AM, Tom Roche <Tom_Roche at pobox.com> wrote:> > As described @ > > https://stat.ethz.ch/pipermail/r-help/2012-November/329442.html > > I now know how to prepare my netCDF data specifying gas concentrations > over a 3D space (dimensions longitude, latitude, and (vertical) level), > so as to call lattice::levelplot() like > > levelplot(conc ~ lon * lat | lev, data=data.frame) > > which labels each panel in the lattice of plots with the name "lev" plus > a graphical indicator of the level value. Alternatively, I can label > each panel with an index (i.e., "1", "2", ...) by calling > > levelplot(conc ~ lon * lat | factor(lev), data=data.frame) > > However I will need to before-and-after compare this to the results of a > reboxing, or 3D regridding, of this data, so I would prefer instead to > label each panel in the lattice with the _value_ of the level (an > atmospheric pressure), rather than the name or index of the level. > How to do that? > > TIA, Tom Roche <Tom_Roche at pobox.com> > > ______________________________________________ > R-help at r-project.org mailing list > 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.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Ken Knoblauch
2012-Nov-18 16:09 UTC
[R] [lattice] how to label panels with variable value (not name)?
Tom Roche <Tom_Roche <at> pobox.com> writes:> > > As described @<<< clipped >>>> > However I will need to before-and-after compare this tothe results of a> reboxing, or 3D regridding, of this data, so I wouldprefer instead to> label each panel in the lattice with the _value_ ofthe level (an> atmospheric pressure), rather than the name orindex of the level.> How to do that? > > TIA, Tom Roche <Tom_Roche <at> pobox.com>maybe, see ?strip.custom in lattice -- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen L?pine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html
Tom Roche
2012-Nov-18 21:03 UTC
[R] [lattice] how to label panels with variable value (not name)?
https://stat.ethz.ch/pipermail/r-help/2012-November/329450.html>> I [can now] prepare my netCDF data specifying gas concentrations over >> a 3D space (dimensions longitude, latitude, and (vertical) level), >> so as to call lattice::levelplot() like>> levelplot(conc ~ lon * lat | lev, data=data.frame)... m>> However I will need to [do before-and-after comparisons of that plot] >> to the results of a reboxing, or 3D regridding, of this data[. Hence] >> I would prefer instead to label each panel in the lattice with the >> _value_ of [its] level (an atmospheric pressure), rather than [its] >> name or indexhttps://stat.ethz.ch/pipermail/r-help/2012-November/329454.html> see ?strip.custom in latticeThat showed me where to look in "the lattice book": see (partial) solution to this problem, and the followup problem, @ https://stat.ethz.ch/pipermail/r-help/2012-November/329479.html Thanks! Tom Roche <Tom_Roche at pobox.com>