[R] legend position help
Greg Snow
538280 at gmail.com
Wed Aug 15 18:22:33 CEST 2012
You can use the grconvertY function to find the position in the
current user coordinates that corresponds to the top of the device
area (instead of using locator).
Look at the "merge" argument to the legend function.
On Wed, Aug 15, 2012 at 10:04 AM, Jinsong Zhao <jszhao at yeah.net> wrote:
> Hi there,
>
> I draw a multiple figure in one plot, like the following:
>
> par(mfcol=c(1,5),mar=c(4,4,0,0)+0.2, oma=c(0,0,3,0))
> plot(1:10, type = "b")
> plot(1:10, type = "b")
> plot(1:10, type = "b")
> plot(1:10, type = "b")
> plot(1:10, type = "b")
>
> Now, I hope to plot the legend like the following:
>
> legend("top", legend=c("Example"), pch = 21, lty = 1, merge = FALSE, horiz =
> TRUE, bty="n", xpd = NA)
>
> There were two problems:
>
> 1) the legend is put inside the fifth figure instead of the top center of
> the whole plot, i.e., the center of the outer top margin.
>
> Now, I use a stupid solution, I replace "top" in the above command with
> locator(1). However, using this solution, the plot have to be in an
> interactive mode, and the position is not accuracy.
>
> 2) the point is connected with the line in the legend. I hope there is a
> space between the two symbols, like --- o instead of ---o. If possible, put
> the point before the line, like o ----. Unfortunately, I don't find any way
> to do that.
>
> Any suggestion will be greatly appreciated.
>
> Regards,
> Jinsong
>
> ______________________________________________
> 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.
--
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com
More information about the R-help
mailing list