[R] Lattice: problem with setting space between plot and legend

David Winsemius dwinsemius at comcast.net
Wed Aug 17 16:34:01 CEST 2011


On Aug 17, 2011, at 9:15 AM, mike1989 wrote:

> Dear R Users,
>
> I am writing code to present my output data (I'm using Lattice  
> Package).
> However, it's essential for me to control space between barchart and  
> legend.
> I've read the package's specification, but unfortunately I haven't  
> spot the
> information how to do this. Here's the code I've written:
>

require(lattice)

> barchart(mymatrix[,1:ncol(mymatrix)], horizontal=FALSE,
> box.width=1, stack=TRUE, border=FALSE, par.settings =  
> simpleTheme(col=my_colors), lty="dotted", lend="butt",

> key=list(space="bottom",
> columns=ncol(mymatrix),
> points=FALSE,
> text=list(colnames(mymatrix)),
> rectangles=list(border=FALSE,size=2, col=my_colors[1:ncol(mymatrix)]),
> border=FALSE, rows=1, between=0.25))

a) You ought to use spaces and linefeeds for readability
b) It appears you are using the key option so the documentation is in  
the .../key section regarding placement:

"Alternatively, [and this comes just after the description of the  
space= options] the key can be positioned inside the plot region by  
specifying components x, y and corner. x and y determine the location  
of the corner of the key given by corner, which is usually one of  
c(0,0), c(1,0), c(1,1) and c(0,1), which denote the corners of the  
unit square. Fractional values are also allowed, in which case xand y  
determine the position of an arbitrary point inside (or outside for  
values outside the unit interval) the key."

Now I will admit that I did not understand what that last sentence  
regarding an "arbitrary point inside the key" might mean on the first  
three readings. I'm hoping it means a "user-determined point inside  
the _plot_". I also cannot figure out from that paragraph or the one  
that follows which corner of the key is being located.

Lack of an included example triggers my do-no-more rule regarding such  
posts.

-- 
David.
>
>
> Thank you for any assistance.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Lattice-problem-with-setting-space-between-plot-and-legend-tp3749919p3749919.html
> Sent from the R help mailing list archive at Nabble.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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list