我试图覆盖两个不同的图。一个是geom_boxplot
,另一个geom_jitter
。我希望每个都有自己的色标。但是当我添加第二个色阶时,我得到了错误
"Scale for 'fill' is already present. Adding another scale for 'fill',
which will replace the existing scale."
我假设我做错了什么。任何建议将不胜感激
这是我的工作代码的粗略示例:
P <- ggplot(dat) +
geom_boxplot(aes(x=ve, y=metValue, fill=metric), alpha=.35, w=0.6, notch=FALSE, na.rm = TRUE) +
scale_fill_manual(values=cpalette1) +
geom_hline(yintercept=0, colour="#DD4466", linetype = "longdash") +
theme(legend.position="none")
P + geom_jitter(dat2, aes(x=ve, y=metValue, fill=atd),
size=2, shape=4, alpha = 0.4,
position = position_jitter(width = .03, height=0.03), na.rm = TRUE) +
scale_fill_manual(values=cpalette2)
dat
并dat2
具有相同的架构,但不同的值。
我发现了几个解决重叠图的例子,但没有一个似乎解决了这个特定问题。