我从我的数据(下面的示例)创建ggplot。我想区分哪些数据点属于哪个PID
。到目前为止好:改变颜色的调色板中ggplot
violin.murgang <- ggplot(nkv.murgang, aes(x = factor("Murgang"), nkv.murgang$NK)) +
geom_violin(color = "black", fill = "darkorange") +
ggtitle("NKV Murgang - Einfamilienhaus") +
labs(x = "Prozess", y = "Nutzen/Konsten \n Verhälhniss") +
stat_summary(geom = "text", fun.y = quantile,
aes(label=sprintf("%1.1f", ..y..)),
position=position_nudge(x=0.4), size=3) +
theme (legend.position = "none") +
stat_summary(fun.data = give.n, geom = "text", position=position_nudge(x=-0.4)) +
geom_jitter(aes(col = PID), width = 0.35)
violin.murgang
的问题是,所有的NKV
数据点在不同的色调的蓝色只显现。我想有不同的颜色。我曾尝试添加此:
scale_colour_brewer(palette="Spectral")
其产生错误:
Error: Continuous value supplied to discrete scale
我如何能实现具有用于geom_jitter
部分不同的颜色?
什么原因导致错误?
谢谢!
我认为brewer颜色只适用于离散变量。看看'scale_colour_gradient'和'scale_colour_gradient2'。 –