Repository navigation
Make bin guides compatible with discrete scales - #3703
Conversation
…cales if the levels follow cut() naming semantics
|
Failure is just standard travis random failure |
clauswilke
left a comment
There was a problem hiding this comment.
The code looks good to me, but I think adding a few comments would be helpful. Also, should the feature of discrete breaks be mentioned somewhere in the docs?
| limits <- scale$get_limits() | ||
| all_breaks <- c(limits[1], breaks, limits[2]) | ||
| bin_at <- all_breaks[-1] - diff(all_breaks) / 2 | ||
| } else { |
There was a problem hiding this comment.
The else branch is sufficiently complicated that a comments would be helpful. In particular, explain that when breaks is not numeric it's expected to be in the (<lower>, <upper>] format. I was very confused by the regex until I figured that out. Also, should this format be mentioned somewhere in the documentation?
| limits <- scale$get_limits() | ||
| all_breaks <- c(limits[1], breaks, limits[2]) | ||
| bin_at <- all_breaks[-1] - diff(all_breaks) / 2 | ||
| } else { |
There was a problem hiding this comment.
See my previous comment. Add some explanation to the code here as well.
|
You are probably right about everything. I'll add some comments and improve the docs |
This PR makes the new bin guides work with discrete scales if the breaks are given in a
cut()compliant format (e.g.(4, 19]).This, most importantly, makes the bin guides work with
geom_contour_filled()but also gives a venue for users to pre-bin their data and still benefit from the new guides.Example:
Created on 2020-01-08 by the reprex package (v0.3.0)