2013-06-17 5 views
0

입니다. ggplot을 처음 사용하고 scale_colour_gradient2() 함수에 문제가 있습니다. 다음 코드에서 인수를 포함 할 때마다 오류가 발생합니다.ggplot의 그래디언트 색상은 R

cor_mat <- matrix(sample(rnorm(100), 49), ncol = 7, nrow = 7) 
rownames(cor_mat) <- c("H1", "H2", "H3", "H4", "H5", "H6", "H7") 
colnames(cor_mat) <- c("H1", "H2", "H3", "H4", "H5", "H6", "H7") 
cor_mat_melt <- melt(cor_mat)   

ggplot(cor_mat_melt, aes(X1, X2, fill = value)) + geom_tile() + labs(x = "", y = "") +  scale_colour_gradient2(low = "red", high = "blue") 

생각들? 감사.

답변

2

크기를 조정할 색이 없을 때 scale_color_gradient을 사용하고 있습니다. scale_fill_gradient을 사용하거나 fill=valuecolor=value

으로 변경하십시오.