How to plot (or label) for interactions plot with more than 9 elements
daaronr opened this issue · comments
I want to plot the interaction in a case with a continuous variable and more than 9 elements. But as you can see below, the templates can only accommodate 9 colors; the rest come out gray ... so we don't know which is which.
- Is there a way to have more than 9 colors?
- Is there a way to different this other than by colors (like dashed lines or some such)?
- Is there a way to label these lines? (Like the
geom_text
commented out below, which creates a mess if you run it.
library(sjPlot)
library(dplyr)
starwars_dup <- bind_rows(replicate(10, starwars, simplify = FALSE)) %>%
mutate(height = height + 10*runif(1, min=-20, max=20),
eye_color_gender = as.factor(paste(eye_color, gender, sep = "_"))
)
bigmodel <- starwars_dup %>%
lm(
height ~ eye_color_gender + mass + eye_color_gender*mass + birth_year,
data=.)
(
plot_bigmodel <- sjPlot::plot_model(bigmodel,
type="pred",
terms=c("mass", "eye_color_gender"),
ci.lvl=NA)
# + geom_text(aes(label = group), vjust=0.25)
)
Note -- crossposted on SO