[R] varying color in scatter3D plot

amish azeem amish.azeem1212 at outlook.com
Thu Oct 15 20:05:38 CEST 2015


Dear R family,
I am trying to develop a 3D Scatterplot for the following data
> dput(fer)
structure(c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 54.682478566783, 73.7179265155391, 56.0442812544372, 123.944575771864, 81.6715941711683, 51.7551364274066, 64.017245155324, 73.3252689749492, 100.096914338008, 94.5597376188789), .Dim = c(10L, 3L), .Dimnames = list(NULL, c("x", "y", "")))

You can notice that I have three columns and 10 rows. I was able to plot 3D scatterplot
library(plot3D)
x<-fer[,1]
y<-fer[,2]
z<-fer[,3]
scatter3D(x, y, z, bty = "g", pch = 18,           col.var = as.integer(fer[,2]),           col = c("black", "blue", "green","orange","red"),          pch = 18, ticktype = "detailed",          colkey = list(at = c(1,2, 3, 4,5), side = 2,           addlines = TRUE, length = 0.5, width = 0.5,          labels = c("M 1", "M 2", "M 3","M 4","M 5")),xlab="Model",ylab="station",zlab="Error" )

You could see that the color of plotted points are varying with respect to values on third column. I want them to vary W.r.t the 2nd column, while keeping fer[,1] on x-axis, fer[,2] on y-axis and fer[,3] on z-axis.I tried to change the input in  "col.var = as.integer(fer[,2])" but to no use.
Kindly help me out.
Thankyou very much in advance,

Amish
 		 	   		  
	[[alternative HTML version deleted]]



More information about the R-help mailing list