简体   繁体   中英

Change the color of a confidence interval band?

I am using the blandr package to make a Bland & Altman plots, and the confidence intervals are surely something that I want to plot:

library(blandr)
x1 <- rnorm(100);x2 <- rnorm(100,mean = 1)
blandr.draw(x1,x2, ciShading = TRUE,ciDisplay=TRUE,plotter = "ggplot")

在此处输入图像描述

I would prefer to change the color of the confidence intervals. They do not respond to any change in fill color as far as I can tell. What can I do?

blandr creates a ggplot object, so you can modify the colors with the ggplot_build method.

library(blandr)
library(ggplot2)
x1 <- rnorm(100);x2 <- rnorm(100,mean = 1)

p <- 
blandr.draw(x1, x2, ciShading = TRUE, ciDisplay=TRUE, plotter = "ggplot")

p_build <- ggplot_build(p)
#> Warning: Use of `plot.data$x.axis` is discouraged. Use `x.axis` instead.
#> Warning: Use of `plot.data$y.axis` is discouraged. Use `y.axis` instead.
p_build$data[[12]][["fill"]] <- "grey"
p_build$data[[13]][["fill"]] <- "steelblue"
p_build$data[[14]][["fill"]] <- "thistle"

grid::grid.draw(ggplot_gtable(p_build))

Created on 2021-06-11 by the reprex package (v2.0.0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM