簡體   English   中英

更改置信區間帶的顏色?

[英]Change the color of a confidence interval band?

我正在使用 blandr package 制作 Bland & Altman 圖,置信區間肯定是我想要的 plot:

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

在此處輸入圖像描述

我更願意更改置信區間的顏色。 據我所知,它們不會對填充顏色的任何變化做出反應。 我能做些什么?

blandr創建了一個 ggplot object,因此您可以使用ggplot_build方法修改 colors。

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

代表 package (v2.0.0) 於 2021 年 6 月 11 日創建

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM