Skip to content

Pass on binwidth and height to geom #4671

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 6 commits into from
Dec 6, 2021
Merged

Conversation

thomasp85
Copy link
Member

Fix #4580

This PR makes stat_bin_hex() write width and height to the data which geom_hex() can pick up instead of deriving the resolution from data. This fixes issues with very sparse data where the bin resolution is not obvious from the bin centers

@thomasp85 thomasp85 requested a review from clauswilke November 16, 2021 13:49
@thomasp85
Copy link
Member Author

I've decided to refactor geom_hex(), both to avoid the weird trick to get the bin width transformed, but more importantly to support non-linear coordinate systems which was an artificial limitation of the geom... @clauswilke can you give it a review again?

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 think this is a good idea. Give me a few days to look this over carefully. On quick glance looks good though.

@j-craggy
Copy link

Not sure what is happening here, but these examples do not run correctly.

https://ggplot2.tidyverse.org/reference/geom_hex.html

ggplot(diamonds, aes(carat, price)) + geom_hex()

Warning message:
Computation failed in stat_binhex():

@yutannihilation
Copy link
Member

@jeffcraggy
Hi, thanks for the report. You need to install hexbin package. I filed a new issue: #4736

@j-craggy
Copy link

j-craggy commented Feb 20, 2022 via email

schloerke added a commit to schloerke/ggplot2 that referenced this pull request Mar 23, 2022
* master: (320 commits)
  Orientation-aware key glyphs (tidyverse#4757)
  Fix warning in geom_violin with draw_quantiles (tidyverse#4654)
  Fix misalignment in geom_dotplot when stackratio != 1 and stackdir != "up" (tidyverse#4734)
  Replace coord_equal in scale-identity.r (tidyverse#4759)
  Unified message format in `geom_smooth()` (tidyverse#4634)
  Add parentheses to mentions of binned_scale in scale-alpha and scale-viridis documentation (tidyverse#4735)
  Update geom-boxplot.r (tidyverse#4744)
  Remove unneeded backslash from diamonds docs (tidyverse#4711)
  Re-document
  Warn on unsupported geoms in annotate() (tidyverse#4721)
  Re-document
  Add Trump to presidential terms dataset (tidyverse#4702)
  Corrects bins / binwidth override documentation (tidyverse#4720)
  Update infrastructure to new best practices (tidyverse#4748)
  remove stringsAsFactor for the mapped_discrete as.data.frame method (tidyverse#4750)
  Workflow updates (tidyverse#4747)
  Ensure output is numeric even if ifelse clause is NA (tidyverse#4692)
  Add non_missing_aes to geom_tile (tidyverse#4683)
  Pass on binwidth and height to geom (tidyverse#4671)
  Check for range == NULL - happens if no data has been added to plot (tidyverse#4682)
  ...
@yutannihilation yutannihilation mentioned this pull request Nov 8, 2022
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.

geom_hex ignores binwidth argument when sample size is small
4 participants