strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science

Home Page:https://strengejacke.github.io/sjPlot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sjPlot_theme enhancement - synchronize font family across plot labels and data labels

coverton-usgs opened this issue · comments

I don't know if this is more of a ggplot issue or a sjPlot enhancement. It currently is very difficult to apply uniform font changes across all aspects of a plot. for instance:

a = plot_model(my_random_model,
  show.values = TRUE,
  title = c("something important"),
  axis.title = c("more details"))

windowsFonts(A = windowsFont("Times New Roman"))

a + theme_sjplot(base_family = "A")

Will show a plot with Times New Roman font for the title, axis headings and labels. But the data values in the center of the plot will remain the default font.

In order to obtain data labels in the correct font, I would need to hide values in the plot_model statement and add them using a custom geom_plot

aa = plot_model(my_random_model,
  show.values = FALSE,
  title = c("something important"),
  axis.title = c("more details"))

windowsFonts(A = windowsFont("Times New Roman"))

aa + theme_sjplot(base_family = "A") + geom_text(aes(label( round(my_random_model@beta,2)), family = "A", nudge_x = 0.25, check_overlap = F)

Perhaps this is something that could be modified in the plot_model object when using theme_sjplot?; i.e.,

> a$layers[[4]]
mapping: label = ~p.label 
geom_text: parse = FALSE, check_overlap = FALSE, na.rm = FALSE ###  <- added here
stat_identity: na.rm = FALSE
position_nudge