[R] Odp: plot with diffrent colour and plotting symbols

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Wed, 19 Mar 2008 15:57:28 +0100

Hi

r-help-bounces_at_r-project.org napsal dne 19.03.2008 14:18:39:

> Dear mailing list members,
>
> I am a new R user, I would like to plot the follewing data
>
> var1 <- c(1,2,1,1,2,1,2,1,2,2)
> var2 <- round(rgamma(10,2,1)/0.1)*0.1
> var3 <- c(0,1,0,1,0,0,0,0,1,0)
> var4 <- c(1,2,2,2,1,1,1,1,1,1)
>
> Var <- data.frame(var1,var2,var3,var4)
> Var <- Var[sort(Var$var1),]
> tt <- Var$var1+((runif(length(Var$var1))/6)-(0.5/6))
> labelname <- c("time 1", "time 2")
>
> plot(tt,var2,xaxt = "n")
> axis(1,1:length(unique(var1)), labelname)
>
> Could you tell me please how can I get diffrent colour and plotting
symbols
> according to var3 and var4, respectively.

Like

plot(tt,var2,xaxt = "n", pch=var3+1, col=var4)

see ?par for customising plot parameters. Beware also that var3 is a vector and also a part of your Var data frame which is sorted differently. So this direct call to var3 and var4 reference var3 and var4 vectors not columns from data frame.

Regards
Petr

>
> Diego!
>
>
>
>



> Looking for last minute shopping deals?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.


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. Received on Wed 19 Mar 2008 - 15:05:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 19 Mar 2008 - 15:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive