Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated labels in risk table #156

Closed
kassambara opened this issue Feb 28, 2017 · 1 comment
Closed

Duplicated labels in risk table #156

kassambara opened this issue Feb 28, 2017 · 1 comment

Comments

@kassambara
Copy link
Owner

@kassambara kassambara commented Feb 28, 2017

(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 added a commit that referenced this issue Feb 28, 2017
@kassambara
Copy link
Owner Author

@kassambara kassambara commented Feb 28, 2017

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

kassambara added a commit that referenced this issue Feb 28, 2017
@kassambara kassambara closed this Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.