0

I am using a code suggested by someone in another question about grouped boxplots, but mine looks like this

single boxplots

instead. I should have 3-4 boxplots (Week in code below) per treatment but they aren't showing up. How can I fix this?

w <- Exp1 %>% 
  ggplot(aes(Treatment, `Vertical Travel Distance (mm)`, fill=Week)) + 
  scale_x_discrete(limits=unique(Exp1$Treatment)) + 
  geom_boxplot()
Martin Gal
  • 16,640
  • 5
  • 21
  • 39
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Aug 09 '21 at 18:00
  • 1
    Use `fill=factor(Week)`, remove `scale_x_discrete`, it's doing nothing. Or pipe `Exp1%>%mutate(Week=factor(Week))%>%ggplot(etc)` to make the legend title prettier. – Rui Barradas Aug 09 '21 at 19:18
  • @MrFlick Thank you for the note - I will for future questions! – jmicciulla Aug 10 '21 at 12:53
  • @RuiBarradas That worked - thank you! I include scale_x_discrete to keep the x axis in the order I want rather than alphabetical. – jmicciulla Aug 10 '21 at 13:15
  • 2
    @MartinGal That didn't work for me but I appreciate the suggestion! – jmicciulla Aug 10 '21 at 13:16

0 Answers0