Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 1 commit into from
Jan 7, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 25, 2022

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).

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

lib/mpl_toolkits/axisartist/axislines.py Outdated Show resolved Hide resolved
@@ -225,8 +237,7 @@ def get_tick_iterators(self, axes):

def _f(locs, labels):
for x, l in zip(locs, labels):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, but

Suggested change
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).

Copy link
Contributor Author

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional as above:

Suggested change
for x, l in zip(locs, labels):
for loc, label in zip(locs, labels):

Copy link
Member

@QuLogic QuLogic left a 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.

lib/mpl_toolkits/axisartist/axislines.py Outdated Show resolved Hide resolved
@anntzer
Copy link
Contributor Author

anntzer commented Jan 27, 2022

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).

@anntzer
Copy link
Contributor Author

anntzer commented Jul 5, 2022

@QuLogic thoughts about my reply above?

@anntzer
Copy link
Contributor Author

anntzer commented Nov 18, 2022

Re-ping @QuLogic per my reply to #22314 (review).

lib/mpl_toolkits/axisartist/axislines.py Outdated Show resolved Hide resolved
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)``.
@QuLogic
Copy link
Member

QuLogic commented Jan 7, 2023

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).

Yes, I'm thinking we should probably start erroring for weird inconsistent input, but that can go in a separate PR.

@QuLogic QuLogic merged commit 8dd1058 into matplotlib:main Jan 7, 2023
@anntzer anntzer deleted the aatoxy branch January 7, 2023 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.