Skip to content

Calculate stat_align() per panel - #5239

Merged
teunbrand merged 4 commits into
tidyverse:mainfrom
teunbrand:stat_align_panel
Mar 23, 2023
Merged

teunbrand merged 4 commits into
tidyverse:mainfrom
teunbrand:stat_align_panel

Conversation

@teunbrand

Copy link
Copy Markdown
Collaborator

This PR aims to fix #5227 and fix #5176, thereby superseding #5177.

Briefly, to prevent the small offset adjust taking on too large values, we calculate the unique x-locations ± offset per panel instead of globally. I think it comes with the following trade-offs.

  • - It has to be computed for every panel, possibly being less efficient than doing it once globally.
  • + To compensate, I tried making determining the unique x-positions faster, by
    • Not taking into account 0-crossings when there is only one group and no stacking needs to occur
    • Unlooping the groupwise 0-crossings calculation for efficiency

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a unit test that covers what this fixes?

@teunbrand
teunbrand merged commit 5f2011f into tidyverse:main Mar 23, 2023
@teunbrand
teunbrand deleted the stat_align_panel branch March 23, 2023 18:01
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_area does not align with geom_line with duplicate x coords geom_area() producing weird areas for some input values

2 participants