You get all levels shown on plot because all levels are used. Levels are dropped if they are not used at all. To remove levels in each facet add scale="free_x"
to facet_grid()
. But this will not work in particular case because you use different statements of x
values in ggplot()
and stat_summary()
calls. I would suggest to add new column before plotting with interaction.
tdat$int<-with(tdat,interaction(Condition,variable,drop=TRUE,sep='-'))
ggplot(tdat,aes(int,value,fill=Condition))+
stat_summary(fun.y='mean', geom='bar')+
geom_point()+
facet_grid(.~variable,scales="free_x")
In this case you can simplify your code without interaction()
because you use also facet_grid()
.
ggplot(tdat,aes(Condition,value,fill=Condition))+
stat_summary(fun.y='mean', geom='bar')+
geom_point()+
facet_grid(.~variable)