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

Font family not getting applied to risk table and p-value in ggsurvplot #245

Closed
Swechhya opened this issue Aug 7, 2017 · 6 comments
Closed

Comments

@Swechhya
Copy link

Swechhya commented Aug 7, 2017

I tried changing the font family for ggsurvplot using the following code:

library(survival)
library(survminer)
fit<- survfit(Surv(time, status) ~ sex, data = lung)
ggsurvplot(fit, risk.table = TRUE,  risk.table.pos = "in", pval = TRUE, ggtheme = theme_classic2(base_family = "Courier New"))

I got the following plot :
image

As you can see in the plot, font family gets applied to all the plot parameters except the risk table and p-value. Is there a way to resolve the issue?

Thank you!

kassambara added a commit that referenced this issue Aug 7, 2017
@kassambara
Copy link
Owner

Fixed now, thanks!

The elements in the risk table are text elements not theme elements.

To change the font family, specify the arguments:

  • ggtheme (for theme elements),
  • and font.family (for text element in the tables),

as follow:

library(survival)
library(survminer)

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

# Visualize
ggsurvplot(fit, 
           risk.table = TRUE,          
           risk.table.pos = "in",      
           pval = TRUE,                
           ggtheme = theme_classic2(base_family = "Courier New"),
           font.family = "Courier New" 
           )

@Swechhya
Copy link
Author

Swechhya commented Aug 7, 2017

Thanks for such a quick fix. I tried using the code you provided. There still seems to be problem with the font family getting applied to the p-value. The font family for p-value is still the default font instead of "Courier New". Is there a way to change the font family of p-value also?

@kassambara
Copy link
Owner

It works for me. Please, make sure that you have installed the latest developmental version.

@Swechhya
Copy link
Author

Swechhya commented Aug 7, 2017

With the latest development version this is the plot that I am getting:
image
As you can see, the risk table now has the "Courier New" as the font family but the p-value text still has the default font.

kassambara added a commit that referenced this issue Aug 7, 2017
@kassambara
Copy link
Owner

Oh sorry, I thought that you were taking about the risk table.

The issue is now fixed for the p-value. Please re-install. It should work. Thanks

@Swechhya
Copy link
Author

Swechhya commented Aug 7, 2017

Thank you for the fix. It works perfectly now.

@Swechhya Swechhya closed this as completed Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants