common legend in arrange_ggsurvplots

一笑奈何 提交于 2021-01-28 07:44:09

问题


I'm trying to combine multiple survival plots, using arrange_ggsurvplots. Each plots was made by ggsurvplot function. Most of them works well. However, it is difficult to combine legends.

let's take an example in survminer packages.

https://rpkgs.datanovia.com/survminer/reference/arrange_ggsurvplots.html

# Fit survival curves
require("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)

# List of ggsurvplots
require("survminer")
splots <- list()
splots[[1]] <- ggsurvplot(fit, data = lung, risk.table = TRUE, ggtheme = theme_minimal())
splots[[2]] <- ggsurvplot(fit, data = lung, risk.table = TRUE, ggtheme = theme_grey())

# Arrange multiple ggsurvplots and print the output
arrange_ggsurvplots(splots, print = TRUE,
  ncol = 2, nrow = 1, risk.table.height = 0.4)

As you can see, the legend was not combined. Each column has it own legend.

I want to combine it. However, common methods with cowplot packages like ggarrange function didn't worked. Is there a better solution for this?

来源:https://stackoverflow.com/questions/57106042/common-legend-in-arrange-ggsurvplots

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!