Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: make unused spines invisible #12241

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
Oct 13, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Sep 23, 2018

PR Summary

Closes #12239

mplot3d turned axis off but for whatever reason the spines were still created, and were marked as visible, so get_tightbbox included their nonsense extents in its calculations. This change just makes the spines not be visible.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak jklymak added this to the v3.0.x milestone Sep 23, 2018
@jklymak jklymak added topic: mplot3d topic: geometry manager LayoutEngine, Constrained layout, Tight layout labels Sep 23, 2018
@jklymak jklymak force-pushed the fix-mplot3d-spines-invisible branch from bc21411 to 57e2133 Compare September 24, 2018 00:05
@@ -2970,6 +2970,9 @@ def set_axis_off(self):
"""Turn off the axis."""
self.axison = False
self.stale = True
for k in self.spines.keys():
self.spines[k].set_visible(False)

Copy link
Member

Choose a reason for hiding this comment

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

to be pedantic, this should be done prior to setting the stale flag to True.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooops. I meant to remove that anyhow..

Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me. I'd like @WeatherGod to click the green button, though.

@jklymak
Copy link
Member Author

jklymak commented Sep 24, 2018

I'll admit I'm a little unclear what ax.set_axisoff is supposed to do versus the spines being marked not visible. It's possible that the proper fix is in axes/_base.py but I hesitated because ax.set_axisoff would wipe out any user customization of the spine visibility.

The other possible fix is for ax.get_tightbbox to check if axison, and pull any spines out of the artist tree if its off. But that seems fiddly.

Frankly, I'm not quite sure why the spines are separate artists from the axis objects. It would seem to me they should be children artists of axis, and then axis could return the correct bbox.

@jklymak jklymak added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Oct 3, 2018
@jklymak
Copy link
Member Author

jklymak commented Oct 9, 2018

ping @WeatherGod if you have a minute

@WeatherGod
Copy link
Member

A long time ago, what appeared as spines used to be a part of the axis (they weren't called that back then), but then we transitioned over to this spines implementation that allowed for all sorts of neat and useful graphs. I think we made them children of axes because it simplified the API that way, but I don't remember for sure. I think the transition was around v1.0 or v1.1?

Copy link
Member

@WeatherGod WeatherGod left a comment

Choose a reason for hiding this comment

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

Yeah, this makes sense in general, just concerned about computation costs.

@jklymak jklymak force-pushed the fix-mplot3d-spines-invisible branch from 9cbed9e to 74849b9 Compare October 10, 2018 02:31
FIX: remove visible logic from _base.py

FIX: also exclued spines tight layout
@jklymak jklymak force-pushed the fix-mplot3d-spines-invisible branch from 74849b9 to 0a926aa Compare October 11, 2018 00:21
@WeatherGod WeatherGod merged commit b424c85 into matplotlib:master Oct 13, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Oct 13, 2018
QuLogic added a commit that referenced this pull request Oct 14, 2018
…241-on-v3.0.x

Backport PR #12241 on branch v3.0.x (FIX: make unused spines invisible)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: geometry manager LayoutEngine, Constrained layout, Tight layout topic: mplot3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3d axes are collapsed by tight_layout
4 participants