[R] plot

Tom Wright tom at maladmin.com
Fri Sep 19 21:25:31 CEST 2014


plot(x=range(x),y=range(c(y1,y2,y3.y4),type='n')
lines(x=x,y=y1,lty=1)
lines(x=x,y=y2,lty=2)
lines(x=x,y=y3,lty=3)
lines(x=x,y=y4,lty=4)

legend('bottomright',c('Y1','Y2','Y3','Y4','Y5'),lty=1:4)


or something like that.


On Fri, 2014-09-19 at 14:11 -0500, Marc Schwartz wrote:
> On Sep 19, 2014, at 10:48 AM, IZHAK shabsogh <ishaqbaba at yahoo.com> wrote:
> 
> > Hi,
> > kindly give me some guide on how to plot the following data in a single line graph that is ( y1,y2,y3,y4 against x) including title and key
> > 
> > y1<-c(0.84,1.03,0.96)
> > y2<-c(1.30,1.46,1.48)
> > y3<-c(1.32,1.47,1.5)
> > y4<-c(0.07,0.07,0.07)
> > x<-c(500,1000,2000)
> > 
> > Thanks
> > Ishaq
> 
> 
> See ?matplot and ?legend
> 
> matplot(x, cbind(y1, y2, y3, y4), type = "l", 
>         main = "Plot Title", ylab = "Y Vals", 
>         xlab = "X Vals")
> 
> legend("right", lty = 1:4, col = 1:4, 
>        legend = c("y1", "y2", "y3", "y4"))
> 
> 
> Regards,
> 
> Marc Schwartz
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list