afex
afex copied to clipboard
afex_plot with geom_jitter crashes when "color" is supplied within data_arg and mapping = "color"
Hi Henrik,
it's impossible to change the color of background data when mapping is set to "color" only. (I would've expected different color of the CI bars and same color of the background points)
library("afex")
model <- mixed(value ~ gender * treatment + (1|id), data=afex::obk.long, method = "S")
data_arg <- list(
position =
ggplot2::position_jitterdodge(
jitter.width = 0.3,
jitter.height = 0,
dodge.width = 0.3
),
color = "red"
)
afex::afex_plot(
model,
dv = "value",
x = "gender",
trace = "treatment",
id = "id",
data_geom = ggplot2::geom_jitter,
mapping = "color",
error = "model",
data_arg = data_arg
)
Error: 'position_jitterdodge()' requires at least one aesthetic to dodge by
However, adding "linetype" to the mapping removes the error and produces the expected figure.
afex::afex_plot(
model,
dv = "value",
x = "gender",
trace = "treatment",
id = "id",
data_geom = ggplot2::geom_jitter,
mapping = c("color", "linetype"),
error = "model",
data_arg = data_arg
)

Best, František