Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Prepare for merging SubplotBase into AxesBase.#18564

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 1 commit intomatplotlib:masterfromanntzer:ss
Sep 25, 2020

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedSep 24, 2020
edited
Loading

It should be possible to merge SubplotBase into AxesBase, with all Axes
having aget_subplotspec() method -- it's just that that method would
return None for non-gridspec-positioned Axes. The advantage of doing so
is that we could get rid of the rather hackish subplot_class_factory,
and the dynamically generated AxesSubplot class, which appears nowhere
in the docs. (See discussion at#18222.)

  • Deprecate most Subplot-specific API: while it's fine for all axes to
    have aget_subplotspec which may return None, it would be a bit
    weird if they all also have e.g. ais_last_row for which it's not
    clear what value to return for non-gridspec-positioned Axes. Moving
    that to the SubplotSpec seems natural enough (and these are pretty
    low-level anyways).

  • Make most parameters to AxesBase keyword-only, so that we can later
    overload the positional parameters to be either a rect or a
    subplot triplet (which should ideally be passed packed as a single
    parameter rather than unpacked, but at least during the deprecation
    period it would be a pain to differentiate whether, inAxes(fig, a, b, c),
    b was intended to be the second index of a subplot triplet
    or afacecolor...)

Due to the order of calls during initialization, Axes3D self-adding to
the figure was problematic. This is already getting removed in another
PR (#18356), so I included the same change here without API changes notes just to
get the tests to pass. However I can put a note in for this PR if it
ends up being ready for merge first.

PR Summary

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings andpydocstyle<4 and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@anntzeranntzer added this to thev3.4.0 milestoneSep 24, 2020
@anntzeranntzerforce-pushed thess branch 2 times, most recently from917e301 to8318108CompareSeptember 24, 2020 21:19
Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

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

This all looks good to me. You could up the test coverage a bit with a some trivial new tests of your 4 new methods. And the test_figure change you made is really testing something different. But, I think thats all minor.

When all done, I think this will be a significant simplification....

@@ -170,7 +170,7 @@ def test_gca():
# Changing the projection will throw a warning
assert fig.gca(polar=True) is not ax3
assert fig.gca(polar=True) is not ax2
assert fig.gca().get_geometry() == (1, 1,1)
assert fig.gca().get_subplotspec().get_geometry() == (1, 1,0, 0)
Copy link
Member

Choose a reason for hiding this comment

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

should you check that the subplot spec is 1, 1, 1?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I think that's an equivalent check?

Copy link
Member

Choose a reason for hiding this comment

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

Ooops, I see. You are indeed correct...

@anntzer
Copy link
ContributorAuthor

is_first_row/is_last_col are not tested by the test suite (that hasn't changed from before the PR), but there are actually examples/tutorials which exercise it so they are actually already getting run.

@tacaswell
Copy link
Member

Do we have any idea why we have this split anymore?

@jklymak
Copy link
Member

I think before, it was harder to get back to a subplot's subplot spec and gridspec. But we've added that tracery now, so we don't need to carry that info around explicitly on the axes?

@anntzer
Copy link
ContributorAuthor

c3de3b6 suggests it was to supportAxes([l, r, w, h]) andSubplot(1, 1, 1) but also for polar plots, but we rarely explicitly instantiate Axes (on the user side) anyways, and we can always overload the constructor (oncefacecolor becomes kwonly).

@@ -49,12 +47,13 @@ def __reduce__(self):
(axes_class,),
self.__getstate__())

@cbook.deprecated("3.4", alternative="get_subplotspec")
Copy link
Member

Choose a reason for hiding this comment

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

The change in the return type needs to be flagged.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

sure

tacaswell
tacaswell previously requested changesSep 25, 2020
Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

I am 👍 to the changes, but want to either handle the 3D axes API change note here or get that merged first.

Anyone can clear this.

It should be possible to merge SubplotBase into AxesBase, with all Axeshaving a `get_subplotspec()` method -- it's just that that method wouldreturn None for non-gridspec-positioned Axes.  The advantage of doing sois that we could get rid of the rather hackish subplot_class_factory,and the dynamically generated AxesSubplot class, which appears nowherein the docs.- Deprecate most Subplot-specific API: while it's fine for all axes to  have a `get_subplotspec` which may return None, it would be a bit  weird if they all also have e.g. a `is_last_row` for which it's not  clear what value to return for non-gridspec-positioned Axes.  Moving  that to the SubplotSpec seems natural enough (and these are pretty  low-level anyways).- Make most parameters to AxesBase keyword-only, so that we can later  overload the positional parameters to be either a rect or a  subplot triplet (which should ideally be passed packed as a single  parameter rather than unpacked, but at least during the deprecation  period it would be a pain to differentiate whether, in `Axes(fig, a,  b, c)`, `b` was intended to be the second index of a subplot triplet  or a `facecolor`...)Due to the order of calls during initialization, Axes3D self-adding tothe figure was problematic.  This is already getting removed in anotherPR, so I included the same change here without API changes notes just toget the tests to pass.  However I can put a note in for this PR if itends up being ready for merge first.
@@ -131,8 +131,6 @@ def __init__(
pseudo_bbox = self.transLimits.inverted().transform([(0, 0), (1, 1)])
self._pseudo_w, self._pseudo_h = pseudo_bbox[1] - pseudo_bbox[0]

self.figure.add_axes(self)
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to break basically every usage of 3D axes?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

No, only those using the rather unidiomaticAxes3D(fig) instead offig.add_subplot(..., projection="3d").

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@tacaswell@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp