kassambara / survminer

Survival Analysis and Visualization
https://rpkgs.datanovia.com/survminer/
506 stars 162 forks source link

Duplicated labels in risk table #156

Closed kassambara closed 7 years ago

kassambara commented 7 years ago

(e-mail from a user)

The at risk table has a label below it, which duplicates the label on the graph itself. To my eyeball the duplication is undesirable. Is there a way to get rid of it?

kassambara commented 7 years ago

Now, a new argument tables.theme is available in ggsurvplot() to apply a specific ggplot2 theme to all the tables under the main survival plots.

Fit survival curves


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

Default output of ggsurvplot()


library(survminer)
ggsurvplot(fit, data = lung,
           risk.table = TRUE,
           cumevents = TRUE,
           palette = "jco"
)

rplot06

Clean tables


Example 1:

library(survminer)
ggsurvplot(fit, data = lung,
           risk.table = TRUE,
           cumevents = TRUE,
           palette = "jco",
           tables.height = 0.2, # specify tables height
           tables.theme = theme_cleantable(), # clean theme for tables
           tables.y.text = FALSE # hide tables y axis text 
)

rplot08

Example 2: change the main theme (ggtheme)

library(survminer)
ggsurvplot(fit, data = lung,
           risk.table = TRUE,
           cumevents = TRUE,
           palette = "jco",
           tables.height = 0.2, # specify tables height
           tables.theme = theme_cleantable(), # theme for tables
           tables.y.text = FALSE, # hide tables y axis text 
           ggtheme = theme_light() # main theme
)

rplot09

Example 3: use different themes for main plot and tables

library(survminer)
ggsurvplot(fit, data = lung,
           risk.table = TRUE,
           cumevents = TRUE,
           palette = "jco",
           tables.height = 0.2, # specify tables height
           tables.theme = theme_minimal() + theme_cleantable(), # theme for tables
           tables.y.text = FALSE, # hide tables y axis text 
           ggtheme = theme_gray() # main theme
)

rplot10

Example 4: Remove axis labels but not tick labels

library(survminer)
ggsurv <- ggsurvplot(fit, data = lung,
           risk.table = TRUE,
           cumevents = TRUE,
           palette = "jco",
           tables.height = 0.2, # specify tables height
           tables.y.text = FALSE, # hide tables y axis text 
           ggtheme = theme_gray() # main theme
)
# Change table axis labels
ggsurv$table <- ggsurv$table + labs(x = NULL, y = NULL) # risk table
ggsurv$cumevents <- ggsurv$cumevents + labs(x = NULL, y = NULL) # cumulative events table
ggsurv # print

rplot