Re: [R] position legend below x-axis title

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed, 02 Jul 2008 06:47:00 -0400

The inset= argument to legend does not depend on usr coordinates.

On Wed, Jul 2, 2008 at 5:41 AM, Anne-Marie Ternes <amternes_at_gmail.com> wrote:
> Dear helpers,
>
> I'm using a R script on several different datasets, which makes that
> axis scales may vary quite a lot from dataset to dataset. So what I'm
> looking for now, is how to automagically find out how to position the
> legend (horizontal) in the space below the x-axis title, and how to
> make sure that the legend is within the limits of the lower inner or
> outer margin?
>
> I'm aware of plot, device and figure regions, and of the "din, fin,
> pin, usr, mai, mar, omi, oma and xpd" parameters, of inner and outer
> margins.
>
> I cannot simply position my legend on "minus something", as that
> depends on "usr" coordinates, and those depend on the scale of the
> y-axis.
>
> I tried finding the ideal spot by taking the figure height and
> subtracting the upper margin, the height of the plot region, and half
> of the lower margin. This is quite tedious and doesn't help me, as I
> get a spot in inches, which doesn't to correspond to the "usr"
> coordinates.
>
> I also tried to convert between inches and "usr" coordinates using
> "xy.coords", but the result did not correspond to the position
> returned by "locator".
>
> I'm also aware of "mtext" and its fabulous arguments "side" and
> "line", but there I loose the functionality of displaying the legend
> symbols.
>
> Finally, I found a hint about using "layout", but there I admit I
> would need more than a hint - a small tutorial or graphical example
> with code would be very helpful.
>
> So, the question is, if there is per chance a way to pass "side" and
> "line" arguments to "legend", and if not, what is the best way to do
> what I try to do? BTW, the plot types involved are mostly line plots
> and barplots.
>
> Thanks a lot for your help,
>
> Anne-Marie
>
> ______________________________________________
> 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.
>



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. Received on Wed 02 Jul 2008 - 10:49:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jul 2008 - 11:31:02 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive