Repository navigation
Make position guides customizable - #3398
Conversation
…tors, exclude position guides from the general guide building code
…coord$transform() vs. arbitrarily rescaling using the limits)
… inappropriate position
hadley
left a comment
There was a problem hiding this comment.
I think this looks good. I'd say take another pass at clarifying anything that's confusing now that you've had a break from it, and lets get a review from @thomasp85.
|
I re-took a look through and I don't see anything that doesn't make sense to me. Initially I was worried that organizing the guides a named list where the names are aesthetics would be slow, but I did some profiling and that doesn't seem to matter. After rereading the code, I think From the brief benchmarking I did, I found that this PR slows down building because it adds two calls per panel to Details |
|
Some more benchmarking suggests that I'm wrong about S3 dispatch and |
|
|
||
| draw_view_scale_axis <- function(view_scale, axis_position, theme) { | ||
| if(is.null(view_scale) || view_scale$is_empty()) { | ||
| panel_guide_label <- function(guides, position, default_label) { |
There was a problem hiding this comment.
Shouldn't all these helpers below be placed in coord-.r they seem global to all coords?
There was a problem hiding this comment.
Right now ViewScales and guide_axis() are only used by CoordCartesian. I think the code could get used in all the Coords eventually, but they aren't used anywhere else yet. I could still easily move them to coord-.r if that's the best place for them.
|
Thanks @thomasp85 for the super thorough review of this! To your questions:
I think I've addressed your comments, but let me know if you'd like a different approach or if I forgot a comment! |
|
There will be facilities for fast text-box dimension calculation down the line without going into C++ so we should be able to get this into ggplot2 proper at some point (not needed for this PR though) Do you have an overview of which packages this will affect? If we could reach out to them as soon as possible we can make sure they are ready for the next release |
|
I think, with the one minor remaining change request, that we should merge this in and begin bracing for impact 🙂 It is better to get a lot of hands on this before we make a release... any objections @hadley ? |
|
The only subclass of a position scale I know about is I think more so than subclasses, extension packages that do things with the built and rendered ggplot2 objects are likely to break (I'm thinking of plotly here, which broke as a result of a previous PR I did). |
|
When you've added a NEWS item you are free to merge... then we'll begin working through any possible consequences |
|
@paleolimbot after this merge some code that used to work is failing removing the faceting works but why now facet with free_x is not ? the breaks and labels have the same length library(ggplot2)
ggplot(mtcars,aes(mpg ,disp)) +
geom_point()+
facet_grid(~cyl,scales="free_x")+
scale_x_continuous(breaks=c(10,15,20,21,25,30),
labels=c("10","15","20","21","25","30") )
#> Error: Breaks and labels are different lengths
ggplot(mtcars,aes(mpg ,disp)) +
geom_point()+
scale_x_continuous(breaks=c(10,15,20,21,25,30),
labels=c("10","15","20","21","25","30") )Created on 2019-10-07 by the reprex package (v0.3.0) |
|
@smouksassi Could you file a separate issue please? I can confirm this problem. |
|
FWIW, we are aware of it as it has cropped up in revdepchecks. @paleolimbot is working through these right now |
|
@clauswilke let me know if we still need to open a new issue it seems it is already taken care of? |
|
I think it never hurts to have an explicit issue of a known problem. @paleolimbot can close it when he submits his fix. |
|
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/ |

This is a PR to address #3322, and allows the same syntax that is currently used to customize non-position guides to be used for position guides. This allows the strategies for dealing with overlapping labels that were implemented in #3375 to actually be used (closes #3281). Currently, these only work for
CoordCartesian, but could easily be adapted toCoordTransas well.The main changes are:
Coords:setup_panel_guides()andtrain_panel_guides(). These are both called fromLayout$setup_panel_guides()at draw time. BothCoordmethods return modified versions of thepanel_params, where theguidesare kept.guide_axis()andguide_none()constructors, which return list S3s similar to the other guides.guide_axis()andguide_none()objects that exist for all other guides.guide_transform(), which allows position guides access to thecoordandpanel_params.Some problems include:
Coord$transform()). I don't know how to get around this, but am open to suggestions.gtablecode to draw this (see this reprex ). Currently the code draws the first guide and issues a warning (there is a test for this).A reprex giving the main syntax:
Details
Created on 2019-07-05 by the reprex package (v0.2.1)