[R] How to make legend with line+ character
mvalle at cscs.ch
Tue Apr 27 06:27:52 CEST 2010
Thanks John and thanks to all!
Seems this requires a lot of effort anyway.
So maybe it is better to take a different approach: take the legend out
of the chart and put it on a plot.new() on the right of the chart, use
only colored letters but make them larger to be visible.
On 27-Apr-10 0:54, John Kane wrote:
> I suspect that you may have to construct the legend by hand (well, by explicit text commands anyway)
> Something like this seems to work and it should not be that difficult to write a function to handle the text commands.
> plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a')
> text(1.4,6, label="-a- ", col="red")
> text(2.5,6, label="dg1")
> --- On Mon, 4/26/10, Mario Valle<mvalle at cscs.ch> wrote:
>> From: Mario Valle<mvalle at cscs.ch>
>> Subject: [R] How to make legend with line+ character
>> To: "r-help at r-project.org"<r-help at r-project.org>
>> Received: Monday, April 26, 2010, 7:32 AM
>> Dear all,
>> I have a multiline plot with each line labeled with a
>> different letter.
>> But I'm not able to make the legend display the same kind
>> of pattern '-a-', instead the letter is overwritten by the
>> line. A simpler legend with only the letter is not very
>> visible and the pt.bg does nothing with letters. Any idea?
>> plot(1:10,10:1,lty=1,type='b', lwd=2,pch='a')
>> legend("left", legend=c("ds1","ds2"), bty='n', col=1:2,
>> Thanks for your help!
>> -- Ing. Mario Valle
>> Data Analysis and Visualization Group
>> | http://www.cscs.ch/~mvalle
>> Swiss National Supercomputing Centre (CSCS)
>> | Tel: +41 (91) 610.82.60
>> v. Cantonale Galleria 2, 6928 Manno, Switzerland |
>> Fax: +41 (91) 610.82.82
>> R-help at r-project.org
>> mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained,
>> reproducible code.
Ing. Mario Valle
Data Analysis and Visualization Group |
Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
More information about the R-help