Skip to content

Better handle position aesthetics in params #3666

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

Merged
merged 2 commits into from
Dec 13, 2019

Conversation

thomasp85
Copy link
Member

revdepchecks uncovered an edge case in direction detection if position aesthetics are given outside aes(). This PR correctly looks in both data and params when figuring out direction

@thomasp85 thomasp85 added this to the ggplot2 3.3.0 milestone Dec 12, 2019
@thomasp85 thomasp85 requested a review from clauswilke December 12, 2019 10:43
@@ -99,7 +99,7 @@ GeomLinerange <- ggproto("GeomLinerange", Geom,

setup_params = function(data, params) {
params$flipped_aes <- has_flipped_aes(data, params, range_is_orthogonal = TRUE)
if (!(params$flipped_aes || all(c("x", "ymin", "ymax") %in% names(data)))) {
if (!(params$flipped_aes || all(c("x", "ymin", "ymax") %in% c(names(data), names(params))))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why it tests for x, ymin, ymax but not y, xmin, xmax in params. Is this correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if has_flipped_aes() returns true it means that it contains y, xmin, and xmax

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, Ok, maybe add a quick comment.

@@ -113,6 +113,7 @@ GeomLinerange <- ggproto("GeomLinerange", Geom,
},

draw_panel = function(data, panel_params, coord, flipped_aes = FALSE) {
browser()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks left over. That's probably why the CI fails.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shit — thanks😅

Copy link
Member

@clauswilke clauswilke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say I understand all of the logic of this PR (I'm not sufficiently familiar with this code), but generally LGTM.

@thomasp85 thomasp85 merged commit e076d9b into tidyverse:master Dec 13, 2019
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

Successfully merging this pull request may close these issues.

2 participants