对于 ggforest(森林图),在 "survminer" 中使用 R 更改轴

Change axis with R in "survminer" for ggforest (forest plot)

当我尝试更改我使用 ggforest(来自包 survminer)生成的森林图中的轴时,该图完全改变了。

例如:

#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

如果我尝试改变轴,就像这样......

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

..it looks like this 有谁知道解决这个问题的方法吗?

这是一个基于 coord_flip 并带有 ylim 选项的解决方案:

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