Skip to content

FIX: update scale on shared axes - #4709

Merged
WeatherGod merged 2 commits into
matplotlib:masterfrom
tacaswell:fix_shared_log
Jul 16, 2015
Merged

WeatherGod merged 2 commits into
matplotlib:masterfrom
tacaswell:fix_shared_log

Conversation

@tacaswell

Copy link
Copy Markdown
Member

Fixes #4450

Or at least the scary part of the scale change not propagating
to all shared axes.

Fixes matplotlib#4450

Or at least the scary part of the scale change not propagating
to all shared axes.
@tacaswell tacaswell added this to the next point release milestone Jul 16, 2015
@jenshnielsen

Copy link
Copy Markdown
Member

👍 Will wait till tomorrow for other comments

Comment thread lib/matplotlib/axes/_base.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does get_siblings() return itself along with siblings? If not, then doesn't the self axes miss out on updating?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It does return it's self

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, do we have to watch out for possible infinite recursion?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no, because this is reaching in and touching the inner bits of all of the axes axis, not coming through the ax.set_xscale method (which is where we would get recursion). My first attempt did use recursion, but I think this is simpler as we don't need the logic to prevent the infinite recursion.

@mdboom

mdboom commented Jul 16, 2015

Copy link
Copy Markdown
Member

👍

Comment thread lib/matplotlib/axes/_base.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this need to be called within the loop? I can't quite remember, but doesn't this method check the data limits for all the siblings anyway? We could improve the performance by calling this once for self and then explicitly setting the limits for the others, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup, just checked:

        if scalex and self._autoscaleXon:
            xshared = self._shared_x_axes.get_siblings(self)
            dl = [ax.dataLim for ax in xshared]
            # ignore non-finite data limits if good limits exist
            finite_dl = [d for d in dl if np.isfinite(d).all()]
            if len(finite_dl):
                dl = finite_dl

So, with this design, there is a potential for a huge performance hit, even for moderately sized plot grids.

`autoscale_view` already looks at siblings, only
call it once.
@tacaswell

Copy link
Copy Markdown
Member Author

I have fixed the quadruple calling, but now the ordering of self.autoscale_view(scaley=False) and self._update_transScale() has been flipped.

@WeatherGod

Copy link
Copy Markdown
Member

Yeah, I think changing up the order is fine. The transforms stack doesn't care about limits, so _update_transScale() can be called either before or after changing the limits. The tricky part is realizing that the limits of the siblings are handled about 3 functions deep in the call to autoscale_view().

WeatherGod added a commit that referenced this pull request Jul 16, 2015
FIX: update scale on shared axes
@WeatherGod
WeatherGod merged commit b6b0e1c into matplotlib:master Jul 16, 2015
@tacaswell
tacaswell deleted the fix_shared_log branch July 16, 2015 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants