Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Common axis labels arrange_ggsurvplot?

$
0
0

How can I add common axis labels to a multi-panel ggsurvplot?

I have created four separate survival plots, see code and plots below. I can combine them together into a single multi-panel plot, see code and plot below. However, I am struggling to work out how to include common axis labels. Ideally I would like a single x-axis label in the middle bottom of the multi-panel plot that reads Days since hatch, and a single y-axis label in the middle left of the multi-panel plot that runs vertically and reads Survival probability.

I would very much appreciate any help.

Create the four plots and label their axes separately:

ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.6, 1), legend.title = "", legend.labs = c(">5% weight", "\u22645% weight"), conf.int = TRUE) + xlab("Days since hatch")
ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.5, 1), legend.title = "", legend.labs = c(">5% length", "\u22645% length"), conf.int = TRUE) + 
  xlab("Days since hatch")
ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.4, 1), legend.title = "", legend.labs = c(">5% body condition", "\u22645% body condition"), conf.int = TRUE) + xlab("Days since hatch")
ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.6, 1), legend.title = "", legend.labs = c("Female", "Male"), conf.int = TRUE) + 
  xlab("Days since hatch")

Plot_1, Plot_2, Plot_3, Plot_4

Create a multi-panel plot:

splots <- list()
splots[[1]] <- ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.6, 1), legend.title = "", legend.labs = c(">5% weight", "\u22645% weight"), conf.int = TRUE) + xlab("") + ylab("")
splots[[2]] <- ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.5, 1), legend.title = "", legend.labs = c(">5% length", "\u22645% length"), conf.int = TRUE) + xlab("") + ylab("")
splots[[3]] <- ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.4, 1), legend.title = "", legend.labs = c(">5% body condition", "\u22645% body condition"), conf.int = TRUE) + xlab("") + ylab("") 
splots[[4]] <- ggsurvplot(fit1, data = dat, pval = TRUE, pval.coord = c(0,0.75), ylim = c(0.6, 1), legend.title = "", legend.labs = c("Female", "Male"), conf.int = TRUE) + xlab("") + ylab("")
figure <- arrange_ggsurvplots(splots, nrow = 2, ncol = 2, print = TRUE)

Multi-panel plot

I have tried to create common axis labels in many ways without success. Most recently I tried:

figure$plot <- figure$plot + labs(xlab = "Days since hatch", ylab = "Survival probability")
ggpar(figure, xlab = "Days since hatch", ylab = "Survival probability")

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>