How can I update aspects of a ggplot2
geom
object after it has been created? I'm using sjPlot
's plot_models()
function to visualize the fixed effects of multiple mixed-effects models, and I'd like to increase the size of some text annotations that it creates with geom_text()
as well as increase the size of errorbar lines that it creates with geom_errorbar()
.
Here's an example:
library(sjPlot)
library(lme4)
data1 <- data.frame(y = sample(c(0, 1), 100, replace = TRUE),
ran_effect = rep(c(1:10), 10),
x1 = rnorm(100),
x2 = rnorm(100, 4, 10))
data2 <- data.frame(y = sample(c(0, 1), 100, replace = TRUE),
ran_effect = rep(c(1:10), 10),
x1 = rnorm(100),
x2 = rnorm(100, 4, 10))
m1 <- glmer(y ~ x1 + x2 + (1 | ran_effect), data = data1,
family = binomial())
m2 <- glmer(y ~ x1 + x2 + (1 | ran_effect), data = data2,
family = binomial())
my_plot <- plot_models(m1, m2, dot.size = 5, show.values = TRUE,
show.p = TRUE) +
theme(line = element_line(size = 4))
I was expecting to see a size
value that I could set when accessing the geom
layers, as discussed in Remove a layer from a ggplot2 chart; however, there is no size
value in either str(my_plot$layers[[3]])
or str(my_plot$layers[[4]])
, which correspond to the geom_errorbar()
and geom_text()
layers, respectively.
Is it possible to update this aspect of a geom
after it has been created? I'd like to do this so that I can continue to use sjPlot
's plot_models()
rather than having to create the plots myself.