Boxplot, how to match outliers' color to fill aesthetics?

后端 未结 4 1126
独厮守ぢ
独厮守ぢ 2020-12-15 20:22

I am trying to match boxplot\'s outliers color to the fill color which is set by aesthetic (scale_colour_discrete).

Here is an example.

m <- ggplo         


        
4条回答
  •  轮回少年
    2020-12-15 21:01

    I had a very similar issue. I wanted to match style with a previous plot, so wanted black borders with coloured fill, and matching outliers.

    My solution was to over-print , once with colour= and the default solid circle point, and once with fill= and an open circle point-shape

    p <- ggplot(mtcars, aes(factor(cyl), mpg))
    p + geom_boxplot(aes(colour=factor(cyl))) + 
        geom_boxplot(aes(fill=factor(cyl)), outlier.shape=21)
    

    boxplot with coloured fill, and black borders and median line

提交回复
热议问题