Reputation: 2253
In R;
I have the following code:
ggsurvplot(curve.histology, conf.int=TRUE,
legend.labs=legend.histology, surv.scale=c("percent"),risk.table=T,
ggtheme = theme_bw(), risk.table.fontsize=3.5, xlim=c(0,5),
ylim=c(0,1), break.time.by=1)
There are four variables in "curve.histology". I want all four graphs to stop at x = 5 like my x-axis. Can anyone help with that?
curve.histology <-
rs.surv(Surv(time,cens)~ordered(histologi)+ratetable(age = age, sex =
sex, year = year), ratetable = poptab, method="ederer2")
Thanks in advance,
C.
Upvotes: 0
Views: 2782
Reputation: 808
IIUC, setting xlim
and expand = 0L
on coord_cartesian()
may help (as long as arranging the margins by theme()
). But, I think you should file an issue to the repository of survminer package since editing the ggplot object inside ggsurvplot is a bit painful...
reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-11-12
library(survminer)
#> Loading required package: ggplot2
#> Loading required package: ggpubr
#> Loading required package: magrittr
library(survival)
fit <- survfit(Surv(time, status) ~ sex, data = lung)
p <- ggsurvplot(fit, data = lung, xlim = c(0, 900), expand = FALSE)
p$plot <- p$plot +
coord_cartesian(xlim = c(0, 900), expand = FALSE) +
theme(plot.margin = margin(5.5, 20, 5.5, 5.5))
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
p
Upvotes: 1