简体   繁体   English

ggforest(森林图)中“幸存者”中的R更改轴

[英]Change axis with R in “survminer” for ggforest (forest plot)

When I try changing the axis ina forest plot I generated using ggforest (from the package survminer) the plot changes completely. 当我尝试使用ggforest(来自包幸存者)生成的森林图中更改轴时,图完全改变。

For Example: 例如:

#Example data set
mydata <- data.frame(A = c(8, 6, 42, 97, 55, 1, 5, 7, 55, 4), 
                     B = c(93, 9, 65, 2, 51, 89, 1, 1, 5, 62), 
                     C = c(68.41, 68.86, 47.26, 31.06, 42.97, 69.16, 47.39, 56.57, 19.63, 45.58),
                     D = c(0, 0, 0, 1, 1, 0, 0, 0, 0, 0),
                     time = c(1.6, 34.6, 1.5, 35.8, 7.7, 38.6, 40.2, 4.7, 37.6, 8.6), 
                     event= c(1, 0, 0, 0, 1, 0, 0, 1, 0, 1))


OS <- mydata$time
Event<-mydata$event
A<-mydata$A
B<-mydata$B
C<-mydata$C
D<-mydata$D


# load packages
library("survival")
library("survminer")

# dependent and independent variables
y <- Surv(OS, Event)
x <- cbind(A, B, C, D)  

#cox regression
cox<-coxph(y~x, data=mydata, method= "breslow")
summary(cox)


#Forest PLot using surv miner

ggforest(cox, alpha = 0.05, plot.title = "Forest plot for Cox proportional hazard model")

Which produces this plot 这产生了这个情节

And if I try to change the axis, like so.. 如果我试图改变轴,就像这样..

ggforest(cox, alpha = 0.05, plot.title = "Forest plot for Cox proportional hazard model", xlim=c(-10,10000))

..it looks like this Does anyone know a solution to this? ..看起来像这样有人知道解决方案吗?

Here is a solution based on coord_flip with the ylim option: 这是一个基于coord_flipylim选项的解决方案:

ggforest(cox, alpha = 0.05, plot.title = "Forest plot for Cox proportional hazard model") +
     coord_flip(ylim=c(10^(-4),10^6))

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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