You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First thank you for this great package. The same issue has been posted [#340] but without an answer yet. I would like to get four survival plots arranged in a grid with a common legend applied to the top (or bottom or right) of the grid.
Actual behavior
I can't figure out how to get a single legend for the four plot when using arrange_ggsurvplot. The only (bad) solution I find, is to remove the legend from all plots except the top right one but this makes it look smaller and uneven with the other plots. The least bad solution I find is to position the legend inside one of the plot but it depends on the data and it doesn't look nice.
Steps to reproduce the problem
require(survival)
require(survminer)
Bad solution 1
fit<- survfit(Surv(time, status) ~ sex, data = lung)
a=ggsurvplot(fit, data = lung, xlab="", title="A", legend="none", legend.title="Sex", legend.labs=c("Male","Female"))
b=ggsurvplot(fit, data = lung, title="B", legend="none", legend.title="Sex", legend.labs=c("Male","Female"))
c=ggsurvplot(fit, data = lung, xlab="",ylab="",title="C", legend="none", legend.title="Sex", legend.labs=c("Male","Female"))
d=ggsurvplot(fit, data = lung, title="D", ylab="",legend="none", legend.title="Sex", legend.labs=c("Male","Female"))
fits <- list(a = a, b = b,c = c, d = d)
arrange_ggsurvplots(fits, print = TRUE, ncol = 2, nrow = 2)
And bad solution 2
c=ggsurvplot(fit, data = lung, title="C", legend=c(0.7,0.7), legend.title="Sex", legend.labs=c("Male","Female"))
fits <- list(a = a, b = b,c = c, d = d)
arrange_ggsurvplots(fits, print = TRUE, ncol = 2, nrow = 2)
Expected behavior
First thank you for this great package. The same issue has been posted [#340] but without an answer yet. I would like to get four survival plots arranged in a grid with a common legend applied to the top (or bottom or right) of the grid.
Actual behavior
I can't figure out how to get a single legend for the four plot when using arrange_ggsurvplot. The only (bad) solution I find, is to remove the legend from all plots except the top right one but this makes it look smaller and uneven with the other plots. The least bad solution I find is to position the legend inside one of the plot but it depends on the data and it doesn't look nice.
Steps to reproduce the problem
Bad solution 1
And bad solution 2
session_info()
The text was updated successfully, but these errors were encountered: