2 years ago
#24442
user345995
How to prevent combining 2 boxplots into 1 on ggplot
I am trying to create a plot with 6 panels showing two boxplots (representing the effect of injury (1 = presence of injury, 0 = absence of injury). The closest I have gotten is this:
ggplot(cell_measurement, aes(Injury, Acceleration_mean)) +
geom_boxplot(alpha=.3, aes(fill = Injury)) +
geom_jitter(size=0.1)+
facet_grid(vars(Animal))
Which has produced: enter image description here
The data looks like this: enter image description here
What it has instead done is merged the Injury to make 0.5 but my issue is that the 0 and 1 group are two distinct groups I am trying to represent on each panel. I have tried changing the Injury groups into 'Presence' and 'Absence' but everything I have tried has not worked.
Any suggestions on how to go about this, please?
Thank you!
(sorry I have not been on here long enough to post actual images)
r
ggplot2
geom
0 Answers
Your Answer