ggplot stat_summary fill issue

Hi,

if I add the fill property, it only displays some of the shapes of stat_summary. No idea why.

this works

boxp <- ggplot(mtcars, aes(gear, disp, fill=vs)) +
  geom_boxplot(outlier.color = NA, width=0.2) +
  stat_summary(fun.y=mean, geom="point", shape=23, size=2,  colour = "black", position = position_dodge(0.2),) +
  labs(x = "Questions", y="Values", title = "Question subgroup", colour = "Conditions")
boxp

this doesn't work:

boxp <- ggplot(mtcars, aes(gear, disp, fill=vs)) +
  geom_boxplot(outlier.color = NA, width=0.2) +
  stat_summary(fun.y=mean, geom="point", shape=23, size=2,  colour ="black", fill="white", position = position_dodge(0.2),) +
  labs(x = "Questions", y="Values", title = "Question subgroup", colour = "Conditions")
boxp

thanks!
ps: it's not clear from the post editor, how to format code??

a line i.e. on its own, with only 3 backticks ``` toggles code format on and off

code looks nicer

thanks, I didn't see this specified anywhere (FAQ or forum general posts)

I get 3 filled diamonds, I think there are only 3 classes of gear, so that makes sense to me.

thanks, sorry but if you remove the fill="white" then you will see the mean for each boxplot (as in first script I posted) ? Instead if I add fill-"white" you only see 3 of those..

how many are you seeing without it ?

besides, I think your code should be

  geom_boxplot(aes(group=gear),outlier.color = NA, width=0.2) +

as I'd only get a single boxplot without that. not the 3 box plots.

Hi, see the image attached. I was trying to have all the mean rectangles to be white..but when I add the fill="white" only 3 appears. The others are gone. Thanks

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.