coding_heart
coding_heart

Reputation: 1295

Change font family in interaction plot in R

I am using sjPlot - a package that builds off ggplot2 which I am new to - and I am trying to change the font family to Times New Roman. Using the example code:

require(sjPlot); require(effects)
fit <- lm(weight ~ Diet * Time, data = ChickWeight)
sjp.int(fit, type = "eff")

However, when I try to add an argument such as:

theme(text = element_text(size = 14, family = "Times New Roman")) 

It doesn't work; nor does it when I try to enter similar code in sjp.setTheme(). Any thoughts? Thanks.

Upvotes: 1

Views: 1256

Answers (1)

Chris
Chris

Reputation: 1615

sjp.SetTheme doesn't allow you to specify font family (you'll find it to be missing from the arg list). I wasn't up for trudging through all of this code to figure out how to alter that function to give a font family spec, but I was able to alter the font family through theme_set:

library(sjPlot)
library(effects)
library(ggplot2)
data("ChickWeight")
fit <- lm(weight ~ Diet * Time, data = ChickWeight)

theme_set(theme_bw(base_family = 'AR BERKLEY'))
sjp.int(fit, type = "eff") 

enter image description here

theme_set(theme_bw(base_family = "Times New Roman"))
sjp.int(fit, type = "eff") 

enter image description here

Upvotes: 3

Related Questions