Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control color based on group in a clm() or cumulative model when using plot() #560

Open
mz555 opened this issue Aug 15, 2024 · 1 comment
Labels
reprex 💾 An example (and data) to reproduce the issue is needed to

Comments

@mz555
Copy link

mz555 commented Aug 15, 2024

I am attempting to change the colours of the estimates in my plot based on the levels of Condition, but the "color = " element in plot() doesn't recognise the grouping. I have tried other solutions from the other issues posted here but nothing works:

Example code:

library(ordinal)
ancova.suit = clm(SuitAfter ~ Condition + SuitB4,
                  data = Historicaldata,
                  link = "cauchit")

library(ggeffects)
plot.suit <- ggeffects::ggpredict(ancova.suit, c("Condition"))
plot(plot.suit, colors = c("blue", "pink"), n_rows = 1, facet = TRUE, show_legend = TRUE)

This produces this:
image

All I want is for the levels ("2" and "3") of Condition to be in different colours.
Is there a way to do this?

Things I've tried:

p <- plot(plot.suit, n_rows = 1,) +
  scale_color_manual(values = c("black", "red"), labels = c("2", "3")) +
  labs(color = "Condition")

Which gives this error:

Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.
@strengejacke
Copy link
Owner

Do you have a reproducible example?

@strengejacke strengejacke added the reprex 💾 An example (and data) to reproduce the issue is needed to label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex 💾 An example (and data) to reproduce the issue is needed to
Projects
None yet
Development

No branches or pull requests

2 participants