I am attempting to overlay two different plots. One is geom_boxplot
, the other geom_jitter
. I would like each to have its own color scale. But when I add the second color scale, I am given the error
"Scale for 'fill' is already present. Adding another scale for 'fill',
which will replace the existing scale."
I am assuming I am doing something wrong. Any advice would be appreciate
This is a rough example of my working code:
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
and dat2
have the same schema, but different values.
I found several examples addressing overlaying graphs but none that appeared to address this specific concern.