Reputation: 41
I would like to color my graph in R by 21 colors, so I set 21 colors:
palette(c(rgb(171,182,62,maxColorValue=255),rgb(158,88,203,maxColorValue=255),
[...]
But when I use this command:
scatter3d(x = red, y = green, z = blue, groups = C1class$V1,
grid = FALSE, surface = FALSE)
It give me an error:
Error in scatter3d.default(x = red, y = green, z = blue, groups = C1class$V1, :
Number of groups (13) exceeds number of colors (8)
How to set the new palette to coloring the graph?
Upvotes: 2
Views: 962
Reputation: 44997
The car::scatter3d()
function ignores the palette by default. If you want to use it with a 9 colour palette, you can set surface.col=1:9
in your call. Modifying lukeA's answer,
library(car)
d <- Duncan
d$type <- as.factor(sample(1:9, nrow(d), TRUE))
palette(rainbow(9)) # Or use your own palette...
scatter3d(prestige ~ income + education | type, data = d, surface.col = 1:9, grid = FALSE,
surface = FALSE)
Upvotes: 2