Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically determine position of plot legend

You can position the key legend manually in most plotting programs. For example, in gnuplot it's done using set key top right. In ggplot2, it's done like this.

Is there a plotting library, script, or simple algorithm that automatically positions the legend such that it overlaps the data in the plot minimally?

What I mean is: Suppose I plot the line y=x. A good place for the legend in that case would be top left or bottom right.

like image 751
Alan Turing Avatar asked Aug 25 '11 22:08

Alan Turing


1 Answers

Try this,

require(Hmisc)
?largest.empty

there are other discussions and functions proposed in R-help archives

like image 173
baptiste Avatar answered Sep 24 '22 02:09

baptiste