更改置信区间带的颜色?

问题描述

我正在使用 blandr 包制作 Bland & Altman 图,置信区间肯定是我想要绘制的:

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

enter image description here

我更愿意更改置信区间的颜色。据我所知,它们对填充颜色的任何变化没有反应。我能做什么?

解决方法

blandr 创建一个 ggplot 对象,因此您可以使用 ggplot_build 方法修改颜色。

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))

reprex package (v2.0.0) 于 2021 年 6 月 11 日创建

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...