Skip to content

BUG: shared log axes lose _minpos and revert to default #7587

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

Closed
QuLogic opened this issue Dec 8, 2016 · 5 comments
Closed

BUG: shared log axes lose _minpos and revert to default #7587

QuLogic opened this issue Dec 8, 2016 · 5 comments
Assignees
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. status: confirmed bug
Milestone

Comments

@QuLogic
Copy link
Member

QuLogic commented Dec 8, 2016

This example showcases two instances where the view limits in 1.5.3 are not the same as when using 2.0.0rc1 with the classic style.

from distutils.version import LooseVersion

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt


if LooseVersion(mpl.__version__) >= LooseVersion('2.0.0'):
    plt.style.use('classic')


cc_t = np.arange(-100, 101, 5) / 1000
cc_concave = np.ones_like(cc_t)

fig, ax = plt.subplots()
ax.plot(cc_t, cc_concave, ls="", marker=".", color="0.7",
        label="xcorr (concave)")
ax.set_title(mpl.__version__)


np.random.seed(0)
freq = np.arange(0.0, 100.0, 0.001)
resp = np.random.rand(*freq.shape) + 1j * np.random.rand(*freq.shape)

fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
ax1.loglog(freq, abs(resp), lw=1.5)
ax1.set_title(mpl.__version__)
ax2.semilogx(freq, np.angle(resp), lw=1.5)
ax2.set_title(mpl.__version__)

plt.show()

For the first plot, with 1.5.3, the resulting image, with view limits (-0.1, 0.15), is:

figure_1

but with 2.0.0rc1 in classic style, its view limits are (-0.1, 0.1):
figure_1-2 0 0rc1

For the second plot, with 1.5.3, the result image, with view limits (10^-3, 10^2), is:
figure_2

but with 2.0.0rc1 in classic style, its view limits are (10^-7, 10^2):
figure_2-2 0 0rc1

The interesting thing is that this view limit is only triggered if something is plotted in both axes.

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Dec 8, 2016
@efiring
Copy link
Member

efiring commented Dec 8, 2016

The first example is the sort of thing we have to expect; classic style brings things close to 1.5.3, but trying to guarantee identical results is the road to insanity. There is nothing wrong with the 2.0 classic version.
The second example is pointing to a major bug in how the invalid zero frequency value is handled with shared axes. The problem is that somehow, having the second log axes is causing the default Bbox._minpos value of 1e-7 to override the actual minimum positive value.

@efiring
Copy link
Member

efiring commented Dec 8, 2016

That second example looks familiar... It seems like we have dealt with this, or at least had it pointed out, some time ago. Or maybe I saw it in devdocs but passed over it without investigating.
The bug is not specific to classic style; it also occurs with the 2.0 default style.

@efiring efiring added status: confirmed bug Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labels Dec 8, 2016
@efiring efiring changed the title Change of view limits in 2.0.0rc1 classic style vs 1.5.3 BUG: shared log axes lose _minpos and revert to default Dec 8, 2016
@QuLogic
Copy link
Member Author

QuLogic commented Dec 8, 2016

Maybe you were thinking of #7410? It seems to be a similar topic.

@efiring
Copy link
Member

efiring commented Dec 8, 2016

This is related to #7493.

@efiring efiring self-assigned this Dec 8, 2016
efiring added a commit to efiring/matplotlib that referenced this issue Dec 9, 2016
Closes matplotlib#7595, matplotlib#7493, matplotlib#7587.
Bbox._minpos is now initialized to [np.inf, np.inf] instead of
[1e-7, 1e-7].
Old code with a colorbar in which the formatter is set to
a LogFormatter and a SymlogNorm is used now works again (although
the results are better in 2.0 if the colorbar is left to handle
the formatter automatically).
LogLocator now has its own nonsingular() method which provides
a reasonable starting point for a log axis when no data have
been plotted.
efiring added a commit to efiring/matplotlib that referenced this issue Dec 10, 2016
Closes matplotlib#7595, matplotlib#7493, matplotlib#7587.
Bbox._minpos is now initialized to [np.inf, np.inf] instead of
[1e-7, 1e-7].
Old code with a colorbar in which the formatter is set to
a LogFormatter and a SymlogNorm is used now works again (although
the results are better in 2.0 if the colorbar is left to handle
the formatter automatically).
LogLocator now has its own nonsingular() method which provides
a reasonable starting point for a log axis when no data have
been plotted.
efiring added a commit to efiring/matplotlib that referenced this issue Dec 11, 2016
Closes matplotlib#7595, matplotlib#7493, matplotlib#7587.
Bbox._minpos is now initialized to [np.inf, np.inf] instead of
[1e-7, 1e-7].
Old code with a colorbar in which the formatter is set to
a LogFormatter and a SymlogNorm is used now works again (although
the results are better in 2.0 if the colorbar is left to handle
the formatter automatically).
LogLocator now has its own nonsingular() method which provides
a reasonable starting point for a log axis when no data have
been plotted.
@QuLogic
Copy link
Member Author

QuLogic commented Dec 13, 2016

Closed by #7598.

@QuLogic QuLogic closed this as completed Dec 13, 2016
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. status: confirmed bug
Projects
None yet
Development

No branches or pull requests

3 participants