An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20050601/003eb75f/attachment.pl
How to name variables in a single plot
3 messages · Amir Safari, Christoph Buser, Gabor Grothendieck
Dear Amari
Why not use legend?
y<- c(1:100)
x1<-seq(0.1,10, by=0.1)
x2<-seq(0.5,50,by=0.5)
mydata<- data.frame( y=y, x1=x1, x2=x2)
matplot(mydata, type = "l" ,xlab="Time",ylab="MSE ", col = 1:3, lty = 1:3)
legend(10,90,c("line1", "line2", "line3"), col = 1:3, lty = 1:3)
You can work with text to place any text within the plot
See ?legend ?text
Regards,
Christoph
--------------------------------------------------------------
Christoph Buser <buser at stat.math.ethz.ch>
Seminar fuer Statistik, LEO C13
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/
--------------------------------------------------------------
Amir Safari writes:
>
>
>
> Dear R Friends ,
>
> I want to name my variables( more than 2 variables in a single plot) within a plot to distinct them from each other, but I cann't. How it is possible? I don't mean x and y axis using xlab or ylab. At the below , it follows some lines, only as an example that you could try please, if it is possible. I really thanks for your attention.
>
> Amir
>
>
>
>
>
> library(graphics)
>
> y<- c(1:100)
>
> x1<-seq(0.1,10, by=0.1)
>
> x2<-seq(0.5,50,by=0.5)
>
> mydata<- data.frame( y=y, x1=x1, x2=x2)
>
> matplot(mydata, type = "l" )
>
> matplot(mydata, type = "l" ,xlab="Time")
>
> matplot(mydata, type = "l" ,xlab="Time",ylab="MSE ")
>
>
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
On 6/1/05, Amir Safari <amsa36060 at yahoo.com> wrote:
Dear R Friends , I want to name my variables( more than 2 variables in a single plot) within a plot to distinct them from each other, but I cann't. How it is possible? I don't mean x and y axis using xlab or ylab. At the below , it follows some lines, only as an example that you could try please, if it is possible. I really thanks for your attention. Amir library(graphics) y<- c(1:100) x1<-seq(0.1,10, by=0.1) x2<-seq(0.5,50,by=0.5) mydata<- data.frame( y=y, x1=x1, x2=x2) matplot(mydata, type = "l" ) matplot(mydata, type = "l" ,xlab="Time") matplot(mydata, type = "l" ,xlab="Time",ylab="MSE ")
example(matplot) gives some alternative ways of doing this. Another way, not shown there, is via text: text(rep(100,3), mydata[100,], colnames(mydata), pos = 2)