Scatter chart and drawer overlay

Based on previous ggplot post boxes with scatter overlay (same variables) ,

I would like to have one square for each day of the week instead of two boxes , and dots with a different color are scattered on it.

The code will look like this:

#Box-plot for day of week effect
plot1<-ggplot(data=dodgers, aes(x=ordered_day_of_week, y=Attend)) + geom_boxplot()

#Scatter with specific colors for day of week
plot2<-ggplot(dodgers, aes(x=ordered_month, y=Attend, colour=Bobblehead, size=1.5)) + geom_point()

#Box-ploy with Scatter plot overlay
plot3<-ggplot(data=dodgers, aes(x=ordered_day_of_week, y=Attend, colour=Bobblehead)) + geom_boxplot() + geom_point()

And the result will be:
1, scatter plot

enter image description here

2, drawer section enter image description here

3, combined chart enter image description here

+4
source share
1 answer

color= aes() geom_point() ggplot() aes(). color= ggplot(), . dodge .

mtcars, OP .

ggplot(mtcars,aes(factor(cyl),mpg))+geom_boxplot()+
  geom_point(aes(color=factor(am)),position=position_dodge(width=0.5))

enter image description here

+5

Source: https://habr.com/ru/post/1529241/


All Articles