Skip to content

afex_plot with geom_jitter crashes when "color" is supplied within data_arg and mapping = "color" #88

@FBartos

Description

@FBartos

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
)

image

Best,
František

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions