0

I am creating a ggplot with the below code:

a <- ggplot(zscoregraph[which(zscoregraph$Grouping=="ER" | zscoregraph$Grouping=="Admission" | zscoregraph$Grouping=="ICU"),],aes(x=name,y=mean, color=Grouping, group=Grouping)) +
  stat_summary(fun=mean,geom="point", size=5) +
  stat_summary(fun=mean,aes(group=Grouping),geom="line",size=1.5, linetype = "solid") +
    geom_hline(yintercept = 0, linetype = "dashed", colour="black")+
  xlab("Test") + ylab("Z-Score")+
  theme_classic() +
  labs(title = "Outcomes") +
  theme(axis.text.x = element_text(angle = 90)) +
  scale_x_discrete(labels= labs)

b <- a+ geom_errorbar(aes(ymin=LL, ymax=UL), width = .2, colour="black") + scale_colour_manual(values = c("darkgoldenrod", "black", "cadetblue"))

I was wanting to add a jitter so the geom points + errorrbar are slightly offset to allow for easy of reading.

I was wondering if anyone may be able to advise?

DW1310
  • 147
  • 7
  • 3
    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 and desired output that can be used to test and verify possible solutions. It's hard to help with plotting when we can't see the plot. – MrFlick Nov 07 '22 at 17:39
  • 1
    In `stat_summary` you can change `geom = "point"` to `geom = "jitter"`. As for the error bar, add `position = "jitter"` outside of `aes` within `geom_errorbar`. – Kat Nov 07 '22 at 18:59

0 Answers0