欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

R語言可視化開發(fā)forestplot根據(jù)分組設(shè)置不同顏色

 更新時間:2022年05月12日 08:58:47   作者:WTRD  
這篇文章主要為大家介紹了R語言可視化開發(fā)使用forestplot根據(jù)分組設(shè)置不同顏色的實現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

分組設(shè)置顏色

library(forestplot)
fn <- local({
  i = 0
  function(..., clr.line, clr.marker){
    i <<- i + 1
    if(i%%4==3){fpDrawNormalCI(..., clr.line = "#000000", clr.marker = "#00B9BF")} #4組中的第3組
    else if(i%%4==0){fpDrawNormalCI(..., clr.line = "#000000", clr.marker = "#C26EFF")} #4組中的第4組
    else if(i%%4==2 ){fpDrawNormalCI(..., clr.line = "#000000", clr.marker = "#6DA500")} #4組中的第2組
    else(fpDrawNormalCI(..., clr.line = "#000000", clr.marker = "#F9675C")) #4組中的第1組
  }
})
tabletext=cbind(c("Outcomes",figure_2_data$Treatmeant),c("CI (95%OR)",figure_2_data$`OR (95% CI)*`),c("P Value", figure_2_data$P))
forestplot(labeltext=tabletext,graph.pos = 2,mean = c(NA,figure_2_data$OR),lower = c(NA,figure_2_data$Low),upper = c(NA,figure_2_data$High),boxsize = 0.5,
            txt_gp=fpTxtGp(label=gpar(cex=1.25),
                         ticks=gpar(cex=1.1),
                         xlab=gpar(cex = 1.2),
                         title=gpar(cex = 1.2)),zero = 1,align = "l",
           is.summary = c(T,T,F,F,F,F,T,F,F,F,F,T,F,F,F,F,T,F,F,F,F),
           col = fpColors(box = c("darkblue","darkred")),
           fn.ci_norm = fn,
           colgap = unit(8,"mm"),
           graphwidth = unit(12,"cm")
           )

效果圖

給每行增加輔助線

line_list_Insuf1=list()
for (i in 1:84) {
  exprs=paste0("line_list_Insuf1$`",i,"`=gpar(lwd=1, columns=1:5, col = '#99999922')")
  eval(parse(text=exprs))
}
line_list_Insuf1$`1`=gpar(lwd=2, columns=1:7, col = '#202020')
line_list_Insuf1$`2`=gpar(lwd=2, columns=1:7, col = '#202020')
# parse 將character轉(zhuǎn)換為expression
# eval 執(zhí)行 expression
# forestplot 函數(shù)里面再加上這句參數(shù)
hrzl_lines = line_list_Insuf1

以上就是R語言可視化開發(fā)forestplot根據(jù)分組設(shè)置不同顏色的詳細(xì)內(nèi)容,更多關(guān)于forestplot分組設(shè)置顏色的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論