2017-12-16 1 views
1

내가 21 개 색상으로 R 내 그래프 색상을 원하는, 그래서 21 개 색상 설정 :R에 더 많은 색상을 설정하는 방법은 무엇입니까?

palette(c(rgb(171,182,62,maxColorValue=255),rgb(158,88,203,maxColorValue=255), 
      [...]      

을하지만이 명령을 사용할 때 :

scatter3d(x = red, y = green, z = blue, groups = C1class$V1, grid = FALSE, surface = FALSE)

그것은 나에게 오류를 제공합니다 :

Error in scatter3d.default(x = red, y = green, z = blue, groups = C1class$V1, : 
    Number of groups (13) exceeds number of colors (8) 

그래프를 채우기 위해 새 팔레트를 설정하는 방법은 무엇입니까?

답변

1

car::scatter3d() 함수는 기본적으로 팔레트를 무시합니다. 9 색 팔레트와 함께 사용하려는 경우 surface.col=1:9을 통화 중에 설정할 수 있습니다. lukeA의 대답 수정,

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) 
관련 문제