Peng Cai
2010-Mar-17 22:50 UTC
[R] Adding text outside (lattice barchart) plotting region.
Hi All, I need some help with adding text at the bottom of the graph (outside of default outline of graph). Say, I need to write "Month: 01 04" below each of the two years in the following R code, something like this: _______________ | | | Plot | |___ __________| 1931 1932 Month: 01 04 # R code require(lattice) barchart(yield ~ year, data = barley, stack=TRUE, col="black", ylim=c(0,85) ) Can anyone help please, thanks in advance, Peng Cai [[alternative HTML version deleted]]
RICHARD M. HEIBERGER
2010-Mar-17 23:22 UTC
[R] Adding text outside (lattice barchart) plotting region.
barchart(yield ~ year, data = barley, stack=TRUE, col="black", ylim=c(0,85), scales=list(x=list(labels=c(expression(atop(March, 1932)), expression(atop(April, 1932))))) ) This gets most of what you want. [[alternative HTML version deleted]]
Jim Lemon
2010-Mar-17 23:27 UTC
[R] Adding text outside (lattice barchart) plotting region.
On 03/18/2010 09:50 AM, Peng Cai wrote:> Hi All, > > I need some help with adding text at the bottom of the graph (outside of > default outline of graph). > > Say, I need to write "Month: 01 04" below each of the two years in the > following R code, something like this: > > _______________ > | | > | Plot | > |___ __________| > 1931 1932 > Month: 01 04 > > # R code > require(lattice) > barchart(yield ~ year, data = barley, > stack=TRUE, > col="black", > ylim=c(0,85) > )Hi Peng, Try using mtext: mtext("Month: 01 04",side=1,line=2,at=0,adj=0) You may have to adjust the last three arguments to get it in the correct position. Jim