-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add a helper to generate xy coordinates for AxisArtistHelper. #22314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@@ -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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional as above:
for x, l in zip(locs, labels): | |
for loc, label in zip(locs, labels): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] = value
where the mutation doesn't really helplegibility. Instead, introduce a
_to_xy
helper that allows writingto_xy(variable=x, fixed=0)
.PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and 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).