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

color by for one half only #15

Open
ScaonE opened this issue Jun 23, 2021 · 1 comment
Open

color by for one half only #15

ScaonE opened this issue Jun 23, 2021 · 1 comment

Comments

@ScaonE
Copy link

ScaonE commented Jun 23, 2021

Dear all,

I'd like to be able to specify a color only for the 2nd half of the plot.
See "reprex" below :

# Not specifying a color, all goes well
ggplot(
  ToothGrowth %>%
    mutate(across(dose, as.character)),
  aes(x = dose, y = len)
) + 
  geom_half_boxplot() +
  geom_half_point() +
  theme_bw()

A

# Color is specified & taken into account for geom_half_point, but alignment is not suitable
ggplot(
  ToothGrowth %>%
    mutate(across(dose, as.character)),
  aes(x = dose, y = len)
) + 
  geom_half_boxplot() +
  geom_half_point(aes(color = supp)) +
  theme_bw()

B

My current issue is that some points are now over the boxplot. I'd like them to stay all on the right-hand side of the boxplot. Any tips ?

@maciejmotyka
Copy link

Use geom_half_point_panel() instead of geom_half_point().

From documentation:

Unlike 'geom_half_point', 'geom_half_point_panel' does not dodge different grouping aesthetics. This allows multiple groups in a single cloud of points

I was also confused by this. I colored by a variable with many levels and the result was a cloud of points similar to regular centered geom_jitter(). It took me much too long to figure this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants