Skip to content

Replace superseded coord_flip() with swapped aesthetics (#476)#477

Open
ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
ishaan-arora-1:fix/replace-coord-flip-476
Open

Replace superseded coord_flip() with swapped aesthetics (#476)#477
ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
ishaan-arora-1:fix/replace-coord-flip-476

Conversation

@ishaan-arora-1
Copy link
Contributor

Fixes #476.

coord_flip() is marked [Superseded] in ggplot2 — replaced with direct aesthetic swapping in ppc_error_scatter_avg() and the deprecated ppc_error_scatter_avg_vs_x().

Instead of building the plot with the axes one way and then flipping with coord_flip(), the x and y aesthetics are now mapped directly to the intended axes. Visual output is identical (all vdiffr snapshots pass unchanged).

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

…scatter_avg (stan-dev#476)

coord_flip() is marked [Superseded] in ggplot2. Replaced with direct
aesthetic swapping (aes(x = y_obs, y = value)) and corresponding label
swaps in ppc_error_scatter_avg() and ppc_error_scatter_avg_vs_x().
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.66%. Comparing base (05800bd) to head (8f679de).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #477      +/-   ##
==========================================
- Coverage   98.66%   98.66%   -0.01%     
==========================================
  Files          35       35              
  Lines        5860     5857       -3     
==========================================
- Hits         5782     5779       -3     
  Misses         78       78              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@jgabry jgabry 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 we need to think about whether we want to do this. The snapshots staying the same only shows that the pictures are unchanged, but with this PR the plot object itself changes. By using remapped aesthetics it changes how user customization works after the plot is created, e.g. scale_x_*, scale_y_*, and axis theme tweaks. So this technically breaks backwards compatibility.

That said, I can see an argument that this new behavior is a bit less confusing for users, since modifying a plot after coord_flip() can be awkward. So this PR is probably an improvement for new users, but it can break existing users' code if they have code that modifies these ppc-error plots. For that reason (not breaking existing code), I would lean towards keeping coord_flip, but I can also see the argument for changing it.

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.

Replace superseded coord_flip() with swapped aesthetics in ppc_error_scatter_avg

3 participants