[R] Smart legend ???

Jim Lemon jim at bitwrit.com.au
Fri Jul 15 11:51:24 CEST 2011


On 07/14/2011 05:20 AM, JIA Pei wrote:
> Hi, all:
>
> Is there an automatic smart legend for R?
> Since my R code is running in a row, which will produce a bunch of R plots
> in a single run, some of the produced plots are really "ridiculous".
> Because my legend is fixed to "topleft", sometimes, which occludes the key
> parts of the figure/plots, but most of the time, the legend works just fine.
>
> I'm wondering is there a smart legend in R? Whenever I set "topleft" but
> occlude the actual plots, the smart legend may reset from "topleft" to
> "topright".
> Or, just try "topleft", "topright", "bottomleft" and "bottomright" in a
> particular sequence, and calculate the occlusion ratio.
> Pick up either the legend with the least occlusion, or the first priority
> legend when some legends are of the same occlusion?
>
>
Hi JIA Pei,
The "emptyspace" function in the plotrix package may be helpful. This 
tries to find the largest empty rectangle on a plot and returns the 
coordinates of the center of that rectangle.

Jim



More information about the R-help mailing list