Reputation: 21
I need help. I did lots of online research trying to find a solution to change the size of the legend text in the risk table using R package survminer. Everything else in the KM plot is adjustable but I cannot change font size for the "Male" "Female" in the lower left corner next to the risk table. Is there any way to change the size? the default size is too large. I also don't want to use color to replace "Male" and "Female". Thanks a lot. enter image description here
tried many solutions and nothing worked.
Upvotes: 2
Views: 1225
Reputation: 26630
You can change values within the ggplot object, e.g.
library(survminer)
#> Loading required package: ggplot2
#> Loading required package: ggpubr
library(survival)
#>
#> Attaching package: 'survival'
#> The following object is masked from 'package:survminer':
#>
#> myeloma
fit <- survfit(Surv(time, status) ~ sex, data = lung)
plot <- ggsurvplot(
fit,
data = lung,
size = 1, # change line size
palette =
c("#E7B800", "#2E9FDF"),# custom color palettes
conf.int = TRUE, # Add confidence interval
pval = TRUE, # Add p-value
risk.table = TRUE, # Add risk table
risk.table.col = "strata",# Risk table color by groups
legend.labs =
c("Male", "Female"), # Change legend labels
risk.table.height = 0.25, # Useful to change when you have multiple groups
ggtheme = theme_bw() # Change ggplot2 theme
)
plot$table$theme$axis.text.y$size <- rel(0.5)
plot$table$theme$axis.text.y$colour <- "black"
plot
Created on 2023-04-20 with reprex v2.0.2
Does that answer your question?
Upvotes: 0