Reputation: 723
How to change the axes-line thickness with ticks?
Data:
library(survminer)
data <- data.frame(time =c(1,2,3,4),
status=rep(c(1,0),4),
n=c(1,2,3,4),
grp = c(1,1,0,0))
obj <- Surv(time = data$time, event=data$status)
fit <- survfit(obj ~ grp, data = data)
My plot:
ggsurvplot(
fit,
data = data,
xlim = c(0, 60),
break.x.by = 20,
xlab = "Day",
ylab = c("Survival probability"),
risk.table = "abs_pct",
font.x = c(12, face = "bold"),
font.y = c(12, face = "bold"),
font.tickslab = c(12),
font.legend = c(12),
risk.table.title = "RISK",
risk.table.col = "black",
size = 1,
tables.theme = theme_cleantable() +
theme(
plot.title = element_text(size = 40),
axis.line.y = element_line(size = 1.5) # Not working
)
)
But it does alter the thickness next to the risk.table
How to do this?
Upvotes: 0
Views: 271
Reputation: 145755
ggsurvplot
returns a list
-like object with both a plot
and table
item. We can modify the plot
element directly like this:
p = ggsurvplot(##... your code from above)
## just for illustration
class(p)
# [1] "ggsurvplot" "ggsurv" "list"
names(p)
# [1] "plot" "table" "data.survplot" "data.survtable"
## adjust the plot theme
p[["plot"]] = p[["plot"]] + theme(axis.line.y = element_line(linewidth = 3))
p
Upvotes: 3