[R] matlab style plotting in R

Stefan Grosse singularitaet at gmx.net
Tue Feb 13 19:32:28 CET 2007


There are many ways if I understood what you indend to do:

example data:
toplot<-data.frame(x=c(1:5,1:5),y=rnorm(10),sbs=c(rep("a",5),rep("b",5)))

1st with plot itself:

plot(y~x,data=toplot,type="n")
lines(y~x,data=subset(toplot,sbs=="a"),type="b",pch=4,col="blue")
lines(y~x,data=subset(toplot,sbs=="b"),type="b",pch=2,col="red")


2nd with xyplot out of the lattice package:
library(lattice)
xyplot(y~x,groups=sbs,data=toplot,pch=c(2,4),main="Title")

to see some variants. My advice is to look at a good documentation at
the homepage (contributed documentation) or book ...


Maria Vatapitakapha wrote:
> Hello
>
> I was wondering how I can achieve matlab style plotting in R,
> in the sense that matlab allows you to plot multiple sets of variables
> within the same
> x-y axes. plot in R does not seem to cater for this. I tried 'overplot' from
> the gplots package but this assumes different y axes for the variables.
>
> any suggestions would be very appreciated
>
> Maria
>
> 	[[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
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list