strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science

Home Page:https://strengejacke.github.io/sjPlot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`sjPlot(type = "pred")` is wonky with color arguments

AntMath opened this issue · comments

Trying to achieve a predicting graph using sjPlot(type = "pred"), I was having issues with the coloring process and discover the following: the "color" argument does nothing on its own. It is only used if aes() is called afterwards.

Example:
data("mtcars")
library(lme4)
fit = lmer(mpg ~ cyl + (1 | carb), data = mtcars)

First graph, "color" does nothing:

(p1 = plot_model(fit, type = "pred", terms = "cyl", color="red"))
image

With aes() added:
(p1 = plot_model(fit, terms = "cyl", type = "pred",color="red")+
aes(color=""))
image
Note that it works even if aes(color) has no value. It works the same way if there is an unrelated value in it (for example; with aes(color = "blue")

It works the same way with the argument "fill" which takes its value from sjPlot(color). From what I gather, sjPlot(color) gives its value to both aes(color) and aes(fill), which then have to be called, even if the aes() call makes no sense.

Some other examples with "fill":

(p1 = plot_model(fit, terms = "cyl", type = "pred",color="red",fill="blue")+
aes(color="blue"))
image
sjPlot(fill) does nothing, as "fill" is not called by aes().

(p1 = plot_model(fit, terms = "cyl", type = "pred",color="red",fill="blue")+
aes(color="",fill=""))
image
Here, sjPlot(fill) has no effect on the color. sjPlot(color) passes its value to both aes(color) and aes(fill).

I could go on, there are many weird related behaviors. An arising issue is that it doesn't seem possible to have two different values for "color" and "fill".