Dear list members, I have a probably simple question concerning scatterplots: I want to draw a plot with one X but several Y columns, so that every group of samples gets a different symbol. My table looks like this: X Y1 Y2 Y3 1 1 2 3 3 5 4 7 5 9 6 11 7 13 8 15 Simple in Excel or StarOffice, but how do I do it in R? Thanks a lot Judith
Hi, you can see: ?matplot Best Vito you wrote: Dear list members, I have a probably simple question concerning scatterplots: I want to draw a plot with one X but several Y columns, so that every group of samples gets a different symbol. My table looks like this: X Y1 Y2 Y3 1 1 2 3 3 5 4 7 5 9 6 11 7 13 8 15 Simple in Excel or StarOffice, but how do I do it in R? Thanks a lot Judith ====Diventare costruttori di soluzioni Became solutions' constructors "The business of the statistician is to catalyze the scientific learning process." George E. P. Box Top 10 reasons to become a Statistician 1. Deviation is considered normal 2. We feel complete and sufficient 3. We are 'mean' lovers 4. Statisticians do it discretely and continuously 5. We are right 95% of the time 6. We can legally comment on someone's posterior distribution 7. We may not be normal, but we are transformable 8. We never have to say we are certain 9. We are honestly significantly different 10. No one wants our jobs Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/palese/
I assume the blanks are actually NAs? If so, try something like (say `df' is the data frame): matplot(df$X, df[,-1], pch=1:3) or refer to the help page for matplot() for more options. Andy> From: judith.baltsar at gmx.de > > Dear list members, > I have a probably simple question concerning scatterplots: I want to > draw a plot with one X but several Y columns, so that every group > of samples gets a different symbol. My table looks like this: > > X Y1 Y2 Y3 > 1 1 > 2 3 > 3 5 > 4 7 > 5 9 > 6 11 > 7 13 > 8 15 > > Simple in Excel or StarOffice, but how do I do it in R? > > Thanks a lot > > Judith > > ______________________________________________ > 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 > >
Something like this will work: foo.df <- data.frame(x = 1:8, y1 = c(1,3,5, NA, NA, NA, NA, NA), y2 = c(NA, NA, NA, 7, 9, 11, NA, NA), y3 = c(NA, NA, NA, NA, NA, NA, 13, 15)) plot(foo.df$x, foo.df$y1, ylim = c(0,20), type = "n") points(foo.df$x, foo.df$y1, pch = 1) points(foo.df$x, foo.df$y2, pch = 2) points(foo.df$x, foo.df$y3, pch = 3) HTH, Andy> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of > judith.baltsar at gmx.de > Sent: Thursday, December 09, 2004 11:41 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Scatterplot question > > > Dear list members, > I have a probably simple question concerning scatterplots: I want to > draw a plot with one X but several Y columns, so that every group > of samples gets a different symbol. My table looks like this: > > X Y1 Y2 Y3 > 1 1 > 2 3 > 3 5 > 4 7 > 5 9 > 6 11 > 7 13 > 8 15 > > Simple in Excel or StarOffice, but how do I do it in R? > > Thanks a lot > > Judith > > ______________________________________________ > 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
<judith.baltsar <at> gmx.de> writes: : : Dear list members, : I have a probably simple question concerning scatterplots: I want to : draw a plot with one X but several Y columns, so that every group : of samples gets a different symbol. My table looks like this: : : X Y1 Y2 Y3 : 1 1 : 2 3 : 3 5 : 4 7 : 5 9 : 6 11 : 7 13 : 8 15 : : Simple in Excel or StarOffice, but how do I do it in R? If you already have this as a data frame or matrix then others have already mentioned matplot. If you are looking for a quick way to get the data into that form in the first place without manually padding it out with NAs then you could represent them as time series and cbind them. Assuming regularly spaced time series you can use ts: Y1 <- ts(c(1,3,5), start = 1) Y2 <- ts(c(7,9,11), start = 4) Y3 <- ts(c(13,15), start = 7) Y <- cbind(Y1, Y2, Y3) plot(Y, plot.type = "single", col = rainbow(3)) # or matplot(1:8, Y)