Replace superseded coord_flip() with swapped aesthetics (#476)#477
Replace superseded coord_flip() with swapped aesthetics (#476)#477ishaan-arora-1 wants to merge 1 commit intostan-dev:masterfrom
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
Fixes #476.
coord_flip()is marked[Superseded]in ggplot2 — replaced with direct aesthetic swapping inppc_error_scatter_avg()and the deprecatedppc_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