0

This solution https://stackoverflow.com/a/71590169/7106842 is effective a changing the font of the title, x-axis, and y-axis labels. But not of the annotated data labels. They are still default font. Is there a way to change those labels as well?

I recognize this isn't a minimally reproducible example but the code below was the original partial solution to the problem.

#incorrect model with labels added by sjPlot
a = (plot_model(sl_distr_model,
                 order.terms = c(1,2,3,4,5,6,7),
                 show.values = TRUE,
                 value.offset = .3,
                 rm.terms = c("taxon_detailAnas platyrhynchos","taxon_detailAnas strepera","logshape","logshape:cadencefactor1h","logshape:cadencefactor2h","logshape:cadencefactor3h","logshape:cadencefactor6h","logshape:cadencefactor12h","logshape:cadencefactor24h"),
                 axis.lim = c(xlimrange_min,xlimrange_max),
                 colors = c("firebrick"),
                 wrap.labels = 60,
                title = c("Plot 3: Intercept parameters by time interval - Relationship bewtween shape and scale gamma parameters of step length distributions 7.429"),
                 axis.title = "Intercept = Red; Ratio of Shape to Rate parameters = Blue"))

#added 2 fonts I had installed
windowsFonts(A = windowsFont("Times New Roman"), B = windowsFont("Century Gothic"))

#incomplete formating
a + theme(text = element_text(family = "A")
  • It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including the code you have tried and a snippet of your data or some fake data. – stefan Sep 26 '22 at 21:50
  • 2
    `geom_text()` and `geom_label()` (or `annotate())`, by extension) take a `family` and `fontface` aesthetic. See the`?geom_label` help page for details and examples – Gregor Thomas Sep 26 '22 at 21:53
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 27 '22 at 00:57

1 Answers1

0

The above code did not change the data label font. The all components of the chart were Times New Roman except for the data labels which remained the system deault (courier), to fix this I had to manually add the relevant values using geom_text() referencing the same font family as the rest of the chart

#correct model without data labels
aa = (plot_model(sl_distr_model,
                order.terms = c(1,2,3,4,5,6,7),
                show.values = FALSE,
                value.offset = .3,
                rm.terms = c("taxon_detailAnas platyrhynchos","taxon_detailAnas strepera","logshape","logshape:cadencefactor1h","logshape:cadencefactor2h","logshape:cadencefactor3h","logshape:cadencefactor6h","logshape:cadencefactor12h","logshape:cadencefactor24h"),
                axis.lim = c(xlimrange_min,xlimrange_max),
                colors = c("firebrick"),
                wrap.labels = 60,
                title = c("Plot 3: Intercept parameters by time interval - Relationship bewtween shape and scale gamma parameters of step length distributions 7.429"),
                axis.title = "Intercept = Red; Ratio of Shape to Rate parameters = Blue"))

aa + theme(text = element_text(family = "B")) + geom_text(aes(label= round(sl_distr_model@beta[2:8],2)), family = "B", nudge_x = 0.25, check_overlap = F)

Now all text is Century Gothic.