-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix geom_rug + coord_flip #2988
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
Conversation
The rugs in `geom_rug` are drawn along an axis depending the `sides` parameter. Since the coordinate system does not alter the `geom` parameters, the `geom` has to alter any parameters that determine where the geoms are plotted. fixes tidyverse#2987
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Overall this looks correct to me.
@@ -66,6 +66,10 @@ GeomRug <- ggproto("GeomRug", Geom, | |||
rugs <- list() | |||
data <- coord$transform(data, panel_params) | |||
|
|||
if (inherits(coord, 'CoordFlip')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we wouldn't test for capabilities by testing for inheritance, but this is how it's done for CoordFlip
all over the ggplot2 code base, so I guess it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first instinct was to use is()
, but it was not used anywhere in the coord base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was other coord features are queried by asking the coord, e.g. coord$is_free()
. So it would probably make sense to introduce coord$is_flip()
. But that's for a different PR.
@@ -66,6 +66,10 @@ GeomRug <- ggproto("GeomRug", Geom, | |||
rugs <- list() | |||
data <- coord$transform(data, panel_params) | |||
|
|||
if (inherits(coord, 'CoordFlip')) { | |||
sides <- chartr('tblr', 'rlbt', sides) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a comment to this line explaining what's happening?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a comment to the block.
@hadley This looks good to me. Any concerns from you? |
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/ |
The rugs in
geom_rug
are drawn along an axis depending thesides
parameter. Since the coordinate system does not alterthe
geom
parameters, thegeom
has to alter any parametersthat determine where the geoms are plotted.
fixes #2987
Created on 2018-11-09 by the reprex package (v0.2.1)