leeper / cregg

Simple Conjoint Analyses, Tidying, and Visualization
Other
50 stars 7 forks source link

Change point shapes in plot of AMCEs or MMs #18

Closed miaicosta closed 5 years ago

miaicosta commented 5 years ago

Please specify whether your issue is about:

Hi Thomas: As mentioned, I'm having trouble manually changing the shapes of points when plotting marginal means or AMCEs. Note that using scale_colour_manual() works but scale_shape_manual() is ignored.

library("cregg")

data("immigration")

mm_by <- cj(immigration, ChosenImmigrant ~ Gender + Education + LanguageSkills, id = ~CaseID, estimate = "mm", by = ~contest_no)

plot(mm_by, group = "contest_no", vline = 0.5) + scale_shape_manual(values=c(1, 2, 3, 4, 5)) + scale_colour_manual(values=c("red", "blue", "green", "purple", "black"))
leeper commented 5 years ago

So this isn't a bug but we should definitely make it clearer how to do this. It requires mapping the grouping variable to shape via aes():

plot(mm_by, group = "contest_no", vline = 0.5) + 
  scale_shape_manual(values=c(1, 2, 3, 4, 5)) +
  scale_colour_manual(values=c("red", "blue", "green", "purple", "black")) + 
  aes(shape = contest_no)

tmp

miaicosta commented 5 years ago

Ah, of course - that makes sense. Thank you!

leeper commented 5 years ago

Closed by https://github.com/leeper/cregg/commit/0afd299dd5103f4a5d946f7dbbfd7bd88ccaf51b