[R] Tables in legend
Vemuri, Aparna
avemuri at epri.com
Sat Feb 7 00:57:34 CET 2009
I need to create a legend for a simple scatter plot in the following
format.
This is Blah1 number1 number2
This is Blah2 number3 number4
.
.
.
This is Blah6 number11 number12
I looked up these help pages and found the following solution.
lStr<-c(Blah1, Blah2,....Blah6, number 1, number2, ...number12)
legend(x="topright",lStr,ncol=3)
So this creates the tabular format I am looking for. But the width of
each column is matched to the width of the longest column. So the legend
now looks like this:
This is Blah1 number1 number2
This is Blah2 number3 number4
.
.
.
This is Blah6 number11 number12
And thus, I have the legend occupying most part of the top half of my
plot. I was wondering if there is any way to fit in the legend compactly
or even better to format the width of columns 2 and 3 in the legend and
remove the blank spaces between them. I have tried rounding off the
number values to 3 digits with no luck.
I hope this is not too ambitious to ask.
Thanks in advance!
Aparna
More information about the R-help
mailing list