[R] how to plot a nice legend?

Jonas Stein news at jonasstein.de
Sun Feb 12 03:07:12 CET 2012

> Wrong? Nothing. You told R to put the legend at c(1,3)
> so it did. If you want it elsewhere you need to specify that.
> legend(-1,3, legend=c("one", "two"), inset=-1, xpd=NA)
> maybe, or some other location?

ok that works fine. Now i understand how to use it.
If i create several plots it would be nice if all legends would 
have the same distance to plots with different scaling.

Can the legend be placed vertically centered, 1cm right to the plot aera?

>> Can i include a legend like this in a standard plot like
>> plot(1:10) too?
>> http://www.r-bloggers.com/wp-content/uploads/2011/03/heatmap.png
> Yes.
> What part of that do you want to duplicate? 

The coloured squares.
for the reader who got to this article and had the same question:
I have just found another nice solution for a colour legend a minute ago

> You can specify colors, symbols, labels, etc. in legend().

can i even invent my own symbols?

> Also, please link to the original blog post, not just the figure, so that
> the author gets some credit and we can see the code used.


kind regards,

Jonas Stein <news at jonasstein.de>

More information about the R-help mailing list