2017-05-15 3 views
1

Lorsque j'essaie de changer l'axe d'un graphe de forêt que j'ai généré en utilisant ggforest (à partir du paquet survminer), le tracé change complètement.Modifier l'axe avec R dans "survminer" pour ggforest (parcelle forestière)

Par exemple:

#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

Et si je tente de changer l'axe, comme si ..

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

..it looks like this Est-ce que quelqu'un sait une solution à cela?

Répondre

0

Voici une solution basée sur coord_flip avec l'option ylim:

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

enter image description here

+0

Merci! Ça a bien marché! – Alex