简体   繁体   中英

How to overlay Geom_Point and Geom_Boxplot in (ggplot2)

I need to overlay a 'Geom_Point' Colored by color, with 'Geom_Boxplot' that does not contain the color aesthetic.

I want to overlay these plots

ggplot(Spheriod, aes(Cellline_Stim, Total.Area, colour = Experiment.No.)) + 
  geom_point(alpha = 0.8)

This and

ggplot(Spheriod, aes(Cellline_Stim, Total.Area)) + 
  geom_boxplot()

And this

My attempt is:

ggplot(Spheriod, aes(Cellline_Stim, Total.Area, colour = Experiment.No.)) + 
  geom_boxplot() +
  geom_point(alpha = 0.8)

However, this creates 3 different boxplots per Experiment no. Not what I want

Thanks for any help

In that case, don't put color in global aesthetics

ggplot(Spheriod, aes(Cellline_Stim, Total.Area)) + 
  geom_boxplot() +
  geom_jitter(aes(color = Experiment.No.), alpha = 0.8)

geom_jitter will make your plot more readable than geom_point

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM