I need to make a lot of boxplots for an upcoming publication. I would like to use ggplot2 because I think it will be more flexible for future projects, but my PI is insisting that I make these plots in the style of base-R. He specifically wants the dashed lines, so that they will appear similar to previous plots we made. I have made an example using the iris dataset to show you, using this code:
plot(iris$Species,
iris$Sepal.Length,
xlab='Species',
ylab='Sepal Length',
main='Sepal Variation Across Species',
col='white')
My question is how to make a similar looking plot using ggplot2?
Here is my attempt:
library("ggplot2")
ggplot(iris) +
geom_boxplot(aes(x=Species,y=Sepal.Length),linetype="dashed") +
ggtitle("Sepal Variation Across Species")
I need the combination of dashed and solid lines, but I cannot make anything work. I have already checked https://stats.stackexchange.com/questions/8137/how-to-add-horizontal-lines-to-ggplot2-boxplot which is very very close but no dashed lines, which we need. Also the outliers are filled circles, which is not the same as base-R.
outlier.color = 'black'
andoutlier.fill = 'white'
to reproduce the circles. – Hodgkinsgeom_boxplot()
and modify what gets passed into github.com/tidyverse/ggplot2/blob/master/R/… by adding such params. – Classical