I\'m trying to recreate this plot without the horrible 3d bar plot and the unclear x axis (these are distinct timepoints and it\'s hard to tell when they are).
It seems to me that a line plot is more intuitive here:
library(forcats)
data %>%
filter(!is.na(`Mean % of auxotrophs`)) %>%
ggplot(aes(x = Timepoint, y = `Mean % of auxotrophs`,
color = fct_relevel(Mutator, c("o","m","n")), linetype=`Ancestral genotype`)) +
geom_line() +
geom_point(size=4) +
labs(linetype="Ancestral\ngenotype", colour="Mutator")
To respond to your comment: Here's a hacky way to stack separately by Ancestral genotype
and then dodge each pair. We plot stacked bars separately for mutS-
and mutS+
, and dodge the bars manually by shifting Timepoint
a small amount in opposite directions. Setting the bar width
equal twice the shift amount will result in pairs of bars that touch each other. I've added a small amount of extra shift (5.5 instead of 5) to create a tiny amount of space between the two bars in each pair.
ggplot() +
geom_col(data=data %>% filter(`Ancestral genotype`=="mutS+"),
aes(x = Timepoint + 5.5, y = `Mean % of auxotrophs`, fill=Mutator),
width=10, colour="grey40", size=0.4) +
geom_col(data=data %>% filter(`Ancestral genotype`=="mutS-"),
aes(x = Timepoint - 5.5, y = `Mean % of auxotrophs`, fill=Mutator),
width=10, colour="grey40", size=0.4) +
scale_fill_discrete(drop=FALSE) +
scale_y_continuous(limits=c(0,26), expand=c(0,0)) +
labs(x="Timepoint")
Note: In both of the examples above, I've kept Timepoint
as a numeric variable (i.e., I skipped the step where you converted it to character) in order to ensure that the x-axis is denominated in time units, rather than converting it to a categorical axis. The 3D plot is an abomination, not only because of distortion due to the 3D perspective, but also because it creates a false appearance that each measurement is separated by the same time interval.