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

How do I change the font for all elements in ggsurvplot?

$
0
0

I've used the following code to plot Kaplan-Meier survival curves and the corresponding risk table. I'd like all elements of the plot and table to have font Arial size 12.

library(survival)
library(survminer)
data(lung)

fit <- survfit(Surv(time, status) ~ sex, data = lung)

png(filename="./plots/lung.sohelp.font.png", width = 6.5, height = 6.5, units = 'in', res=150)     

ggsurvplot(fit, title="Survival by Sex in 'lung' Data", xlab = "Follow Up Time (Days)",
conf.int = FALSE, 
pval=TRUE, 
pval.method=TRUE, 
risk.table=TRUE,
risk.table.pos="out",
risk.table.col="black",
risk.table.y.text.col=FALSE,
tables.theme = theme_cleantable(),
legend.labs=c("Male","Female"),
font.tickslab = c(12),
legend.title="Sex",
ggtheme = theme_classic2(base_size=12, base_family = "Arial"),
           font.family = "Arial"
   )

dev.off()

Plot: https://i.stack.imgur.com/5ZG30.png

I notice a few things about this plot:
1. The Male/Female labels in the risk table are smaller than the font 'Number at risk'.
2. The legend and axis fonts looks smaller than the main title and p-value fonts.
2. The numbers in the plot and risk table do not look like Arial font.
3. Without the option font.tickslab = c(12) the tick marks are too small. This seems redundant to the ggtheme option.

How can I apply the same font (Arial, 12) to all elements of the plot and risk table? Thanks.


Viewing all articles
Browse latest Browse all 206126

Trending Articles



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