Skip to content

Rewrite guide_axis() and rename to draw_axis() #3349

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

Conversation

paleolimbot
Copy link
Member

This is a PR to prepare for improvements in axis guides as part of #3322. This PR renames the internal function guide_axis() to draw_axis() and includes a complete rewrite of (what is now) draw_axis().

Renaming guide_axis() to draw_axis() is necessary to make way for an exported guide_axis() function that returns a guide (instead of a grob). I used the term "draw" because it is used in many places in ggplot2 for functions that return grobs.

The rewrite of draw_axis() is necessary because the current code is difficult to read and contains much duplication. This makes it difficult to change or improve, as is planned for #3322. The rewrite does not introduce any visual changes in the current tests, and I didn't add any new tests because I couldn't find any part of axis appearance that wasn't already tested between the guides and themes.

@paleolimbot
Copy link
Member Author

I had to modify combine_elements() (in theme.r) to fix the travis build fail for R 3.1 and 3.2. I'm honestly not sure why the builds passed for all the other versions...it looks like calc_element() was never designed to be used for theme "elements" that aren't list() S3s (like tick lengths). @clauswilke I know you're working on theme inheritance, and so if the way I handled this isn't correct let me know. The previous version calculated the tick lengths itself, which seemed redundant to me as the inheritance is defined elsewhere.

@paleolimbot paleolimbot requested a review from hadley May 31, 2019 18:44
@clauswilke
Copy link
Member

I'm Ok with the change in combine_elements(). The current way of doing things where code all over the place does it's own inheritance calculations is bad. All of this should be centralized and better formalized.

#' @param e2 An element object from which e1 inherits
#'
#' @noRd
#'
Copy link
Member

Choose a reason for hiding this comment

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

Need to bring this function up to code, since you've touched. (In this case, that's just restyling) — https://style.tidyverse.org/functions.html#return

@paleolimbot paleolimbot merged commit 0f929a1 into tidyverse:master Jun 4, 2019
@paleolimbot paleolimbot deleted the issue-3322-draw-axis-refactor branch June 4, 2019 20:27
@lock
Copy link

lock bot commented Dec 1, 2019

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/

@lock lock bot locked and limited conversation to collaborators Dec 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants