plt.stairs: fix unit handling for orientation="horizontal"#31666
Conversation
| else: | ||
| edges, values, baseline = self._process_unit_info( | ||
| [("y", edges), ("x", values), ("x", baseline)], kwargs) |
There was a problem hiding this comment.
Since vertical is the default, should it be the fallback position? Or will this error out if an orientation besides horizontal or vertical is provided?
There was a problem hiding this comment.
I just followed the convention that is used in mpatches.StepPatch (in patches.py) to which orientation is passed. The current behavior is that any value that is not "vertical" will be interpreted like "horizontal".
One can of course change this behavior, but that was not my intention in this PR.
There was a problem hiding this comment.
I hear that that's a separate discussion. I'm also wondering why stairs has to do unit processing if it's being done inside the patch creation code. Is it cause of:
And if so can that information be populated from patch.get_data()?
There was a problem hiding this comment.
The issue is that Artists are currently not responsible for data limit handling. For the patch itself, this is done in add_patch() through _update_patch_limits(). But I suspect this cannot handle the sticky edges of the baseline, and it would not be reasonable to special case this there. Therefore, the baseline handling is left directly to stairs(), which implies the need for unit conversion.
The long-term solution will be #30342. I don't think a partial rewrite to handle the current limitations in another way is reasonable. Therefore, the proposed minimal fix is the way to go.
|
Thanks for the fix! |
…666-on-v3.11.x Backport PR #31666 on branch v3.11.x (plt.stairs: fix unit handling for orientation="horizontal")
PR summary
plt.stairs or Axes.stairs calls
self._process_unit_infoas required for e.g. time dimensions on one axis. This PR introduces a distinction between vertical and horizontal orientation to fix the unit processing for orientation="horizontal".Example
AI Disclosure
No AI was used for this PR.
PR checklist