各位大佬,请问R运行图片时为何会出现下面这个错误提示呀?
Error: Must request at least one colour from a hue palette.
当画其他图形时就可以,但是用自己写的这个函数出图就报错。。。
只是画个密度图而已,用w加权了一下(weighting),样本量五千多
plot <- function(pTitle, pData, x, y, w = NULL){
ggplot(pData, aes(x = x, fill = as.factor(y))) +
geom_density(aes(weight = w, y = ..scaled..), alpha = 0.5, colour = "grey50") +
geom_rug() +
labs(title = pTitle, x = "x", y = "Density")
}