在使用rgl plot3D绘图时,我使用的内容如下:
col = as.integer(as.factor(data[[input$colorBy]])))
plot3d(d[,1], d[,2], d[,3], type=type, col=col, add=TRUE)然而,如果有超过10个不同的因素,这将重复颜色。有没有办法扩展这一点,使颜色永远不会重复,并且(理想情况下)颜色跨越色彩空间的很大范围?
发布于 2015-04-04 01:23:13
有许多方法可以自己设置颜色。我在下面的示例中使用了z值来设置颜色,但您当然可以使用分组变量、转换等来设置颜色。以下是一些选项:
# Fake data
dat = data.frame(x=sort(runif(100,0,100)), y=runif(100,0,100))
dat$z = dat$x + dat$y
dat = dat[order(dat$z), ]
# hcl colors (I've scaled z so that the h value ("hue") ranges from
# zero to 350 (where the hue scale ranges from 0 to 360 degrees))
plot3d(dat, col=hcl(350*(dat$z - min(dat$z))/(max(dat$z) - min(dat$z)), 100, 65))
# Create a color ramp function (from red to green to blue in this case)
colFunc = colorRamp(c(rgb(1,0,0), rgb(0,1,0), rgb(0,0,1)))
cols=colFunc(dat$z/max(dat$z))
plot3d(dat, col=rgb(cols, maxColorValue=255))https://stackoverflow.com/questions/29435537
复制相似问题