[R] Lattice: problem with setting space between plot and legend
Bert Gunter
gunter.berton at gene.com
Wed Aug 17 17:19:33 CEST 2011
(Note: Posted at the suggetsion of David Winsemius, to whom I already
sent a private reply).
Inline Below.
On Wed, Aug 17, 2011 at 7:34 AM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> 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.
> David.
>>
I don't think so. Here's my translation of the Help file:
There are 2 coordinate systems at play here, that of the plot and that
of the key. The plot's coordinate system is native, and is used by the
x and y components of the space component of key. The key's coordinate
system is 0 to 1 on both axes and specifies the key coordinate that is
placed at the x and y plot location. Hence, space = list (x=10, y =
2,corner = c(1,0)) says "place the right lower corner of the key at
plot location (10,2). Replacing the corner component by c(.5,.5)
means "place the center of the key at that location on the plot."
Cheers,
Bert
--
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."
-- Maimonides (1135-1204)
Bert Gunter
Genentech Nonclinical Biostatistics
More information about the R-help
mailing list