-
Notifications
You must be signed in to change notification settings - Fork 2.1k
position_dodge2() should handle both point and interval geoms #2480
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
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Slightly more minimal reprex: library(ggplot2)
df <- tibble::tribble(
~g, ~x, ~y,
"x", "1", 1,
"x", "1", 2,
"x", "1", 3,
"y", "1", NA,
"x", "2", 1,
"x", "2", 2,
"x", "2", 3,
"y", "2", 4,
"y", "2", 5,
"y", "2", 6
)
ggplot(df, aes(x, y, colour = g)) +
geom_boxplot() +
geom_point(position = position_dodge(width = 0.75))
#> Warning: Removed 1 rows containing non-finite values (stat_boxplot).
#> Warning: Removed 1 rows containing missing values (geom_point). ggplot(df, aes(x, y, colour = g)) +
geom_boxplot() +
geom_point(position = position_dodge2(width = 0.75))
#> Warning: Removed 1 rows containing non-finite values (stat_boxplot).
#> Warning: Removed 1 rows containing missing values (geom_point). Created on 2018-05-09 by the reprex package (v0.2.0). |
I think the key problem is that |
This is going to require more thinking about how dodging works, and it's technically a feature not a bug, so I'm going to move to a future ggplot2 release. |
probably wise! (for anyone in need of an ad hoc solution, see #2481) |
Closing in favour of #3022 which has more discussion |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Displaying raw data together with box plots can be useful.
If using both 'x' and 'fill' aesthetic geom_boxplot() handles NA's elegantly through the new position_dodge2(), but unfortunately geom_point() with a matching 'colour' aesthetic is misaligned with the boxes both when using position_dodge() and position_dodge2().
This problem only occurs when handling NA's, and position_dodge() and position_dodge2() gets it wrong in different ways:
The text was updated successfully, but these errors were encountered: