Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5686.

Briefly, contour_breaks() will use a user-provided function even if bins and binwidth are NULL.
A missing binwidth argument is defaulted to 1/10th the available range.

Reprex from #5686:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

ggplot(faithfuld, aes(waiting, eruptions, z = density)) +
  geom_contour(
    breaks = \(x, y) seq(x[1], x[2], length.out = 4)
  )

Created on 2024-02-23 with reprex v2.1.0

@teunbrand teunbrand force-pushed the contour_breaks_function branch from a2e269e to 7f13f47 Compare February 23, 2024 10:33
@teunbrand teunbrand requested a review from thomasp85 February 28, 2024 09:27
@teunbrand teunbrand added this to the ggplot2 3.5.1 milestone Mar 5, 2024
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

Are there other binning stats where the old behaviour is present? I think it is important that we ensure all behaves similarly

@teunbrand
Copy link
Collaborator Author

I don't think so because it appears that other binning stats don't accept functions for the breaks argument, see also #4561.

@teunbrand teunbrand merged commit d05f8a4 into tidyverse:main Mar 18, 2024
@teunbrand teunbrand deleted the contour_breaks_function branch March 18, 2024 10:54
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.

Passing a function to breaks= in stat/geom_contour does not work (as long as both bins= and binwidth= are NULL)
2 participants