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@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.