I would like to distinguish every boxplot’s outliers by shape. For example boxplot 1 uses crosses, boxplot 2 uses circles etc.
I tried to achieve this by doing
ggplot(diamonds, aes(x = cut, y = price)) + geom_boxplot(outlier.shape = c(0, 1, 2, 3, 4))
and by simply doing
ggplot(diamonds, aes(x=cut, y=price, shape=cut)) + geom_boxplot()
Both options fail. How can I achieve different outlier shapes for each boxplot?
>Solution :
You could use the outlier.shape argument have to assign them by NULL like this:
library(ggplot2)
ggplot(diamonds, aes(x=cut, y=price, shape = cut)) +
geom_boxplot(outlier.shape=NULL)

Created on 2023-10-27 with reprex v2.0.2