Hi All, I have data for two groups, group with 100 points and group B with 15 points. i needed plot these two groups in one scatter plot, each group with a different color. I tried plot3d(data, col = c("red", "blue")[c(rep(1, 100), rep(2, 15))], pch=20) . this works but the graph does not look good. the other option that I tried is scatterplot3d(data, type="p", highlight.3d=T, pch=16) where the graph looks much nicer but i do not know how to have each group with a different color. Does anyone know how to do it? Thanks -- View this message in context: http://www.nabble.com/colored-3d-scatter-plot-tp15822670p15822670.html Sent from the R help mailing list archive at Nabble.com.
SNN wrote:> > > Hi All, > > I have data for two groups, group with 100 points and group B with 15 > points. i needed plot these two groups in one scatter plot, each group with > a different color. I tried > > plot3d(data, col = c("red", "blue")[c(rep(1, 100), rep(2, 15))], pch=20) . > this works but the graph does not look good.I guess from package rgl?> the other option that I tried is > > scatterplot3d(data, type="p", highlight.3d=T, pch=16) where the graph looks > much nicer but i do not know how to have each group with a different color.I guess from package scatterplot3d? I'd do it that way for both packages: library("rgl") plot3d(iris, col = rep(c("red", "blue"), c(100, 15)), size = 3) library("scatterplot3d") scatterplot3d(data, color = rep(c("red", "blue"), c(100, 15)), pch=16) Uwe Ligges> Does anyone know how to do it? > Thanks > >
I tried scatterplot3d(data, color = rep(c("red", "blue"), c(100, 15)), pch=16) and I am getting the following error message, Error in plot.xy(xy.coords(x, y), type = type, ...) : invalid color name Does anyone know what he problem is? -- View this message in context: http://www.nabble.com/colored-3d-scatter-plot-tp15822670p15835650.html Sent from the R help mailing list archive at Nabble.com.
SNN wrote:> > I tried > > scatterplot3d(data, color = rep(c("red", "blue"), c(100, 15)), pch=16) and I > am getting the following error message, > > > Error in plot.xy(xy.coords(x, y), type = type, ...) : > invalid color name > > Does anyone know what he problem is?Hi Nancy, When you "rep" your colors, the second argument should be a number equal to the number of values. That is, if "data" contains 100 x, y and z components, try: scatterplot3d(data,color=rep(c("red","blue"),50),pch=16) My guess is that you are generating NAs or something with your version. Jim
Thank you all for your help. SNN wrote:> > > > Hi All, > > I have data for two groups, group with 100 points and group B with 15 > points. i needed plot these two groups in one scatter plot, each group > with a different color. I tried > > plot3d(data, col = c("red", "blue")[c(rep(1, 100), rep(2, 15))], pch=20) . > this works but the graph does not look good. > > the other option that I tried is > > scatterplot3d(data, type="p", highlight.3d=T, pch=16) where the graph > looks much nicer but i do not know how to have each group with a different > color. > > Does anyone know how to do it? > Thanks > > >-- View this message in context: http://www.nabble.com/colored-3d-scatter-plot-tp15822670p15885386.html Sent from the R help mailing list archive at Nabble.com.