I am trying to change the aesthetics of my plot_model() graph and am struggling. Specifically, I'd like to:
Current graph output when using the code below:
Here is the code I am currently using:
library(lme4)
library(ggplot2)
library(sjPlot)
# Run the model
plotModel <- glmer(used ~ BareGround + ConiferTreeCanopy + DeciduousTreeCanopy +
Developed + MesicGrass + MesicShrub + Water + XericGrass +
XericShrub + (1|id) + (1|month),
family = binomial(link = "logit"),
data = plotData, na.action="na.fail")
# Plot the results
set_theme(base = theme_light())
state1plot <- plot_model(plotModel, show.values = TRUE, show.p = FALSE,
value.offset = 0.3, title = "",
axis.labels = c("Xeric Shrubs", "Xeric Grasses", "Water",
"Mesic Shrubs", "Mesic Grasses", "Developed",
"Deciduous Tree Canopy", "Conifer Tree Canopy",
"Bare Ground"),
axis.lim = c(0.01, 20),
colors = c("#C43302", "#EDAA25"),
vline.color = "#061423",
dot.size = 8, line.size = 3) +
theme(text = element_text(size = 20))
state1plot
Haven't found any arguments to achieve that directly via plot_model
. But one option would be to manipulate the ggplot
object directly. To this end you first have to figure the index of the hline
and the text
layers. Then set the size
for these directly via the aes_params
element.
As you provided no example data I use one of the default examples from ?lme4::glmer
:
library(lme4)
#> Loading required package: Matrix
library(ggplot2)
library(sjPlot)
# Run the model
plotModel <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial
)
# Plot the results
set_theme(base = theme_light())
state1plot <- plot_model(plotModel,
show.values = TRUE, show.p = FALSE,
value.offset = 0.3, title = "",
axis.labels = c(
"Xeric Shrubs", "Xeric Grasses", "Water", "Mesic Shrubs",
"Mesic Grasses", "Developed", "Deciduous Tree Canopy",
"Conifer Tree Canopy", "Bare Ground"
), axis.lim = c(0.01, 20), colors = c("#C43302", "#EDAA25"),
vline.color = "#061423", dot.size = 8, line.size = 1
) +
theme(text = element_text(size = 20))
# vline
state1plot$layers[[1]]$aes_params$size <- 4
# labels
state1plot$layers[[4]]$aes_params$size <- 8
state1plot