Add a helper to generate xy coordinates for AxisArtistHelper.#22314
Add a helper to generate xy coordinates for AxisArtistHelper.#22314QuLogic merged 1 commit intomatplotlib:mainfrom
Conversation
| @@ -225,8 +237,7 @@ def get_tick_iterators(self, axes): | |||
|
|
|||
| def _f(locs, labels): | |||
| for x, l in zip(locs, labels): | |||
There was a problem hiding this comment.
Optional, but
| for x, l in zip(locs, labels): | |
| for loc, label in zip(locs, labels): |
would be a bit clearer. in self._to_xy(x, const=self._pos) x can be a y-coordinate depending on self._pos, so better use self._to_xy(loc, const=self._pos).
| @@ -298,8 +303,7 @@ def get_tick_iterators(self, axes): | |||
|
|
|||
| def _f(locs, labels): | |||
| for x, l in zip(locs, labels): | |||
There was a problem hiding this comment.
Optional as above:
| for x, l in zip(locs, labels): | |
| for loc, label in zip(locs, labels): |
QuLogic
left a comment
There was a problem hiding this comment.
This appears to make a different Path for loc='right', nth_coord=0 and loc='top', nth_coord=1.
True, but does a "right x-axis" or a "top y-axis" even make sense? (to be clear, previously a right x-axis would be a 0-1 x-axis at y=0 and now it's at y=1) If anything we should just make these error out (which I can do as part of this PR or of a followup). |
|
@QuLogic thoughts about my reply above? |
|
Re-ping @QuLogic per my reply to #22314 (review). |
AxisArtistHelper can generate either x or y ticks/gridlines depending on the value of self.nth_coord. The implementation often requires generating e.g. shape (2,) arrays such that the nth_coord column is set to a tick position, and the 1-nth_coord column has is set to 0. This is currently done using constructs like ``verts = [0, 0]; verts[self.nth_coord] = value`` where the mutation doesn't really help legibility. Instead, introduce a ``_to_xy`` helper that allows writing ``to_xy(variable=x, fixed=0)``.
Yes, I'm thinking we should probably start erroring for weird inconsistent input, but that can go in a separate PR. |
AxisArtistHelper can generate either x or y ticks/gridlines depending
on the value of self.nth_coord. The implementation often requires
generating e.g. shape (2,) arrays such that the nth_coord column is
set to a tick position, and the 1-nth_coord column has is set to
0. This is currently done using constructs like
verts = [0, 0]; verts[self.nth_coord] = valuewhere the mutation doesn't really helplegibility. Instead, introduce a
_to_xyhelper that allows writingto_xy(variable=x, fixed=0).PR Summary
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).Documentation
doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).