Skip to content

Make logscale bar/hist autolimits more consistents. #14581

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
Aug 12, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 20, 2019

See changelog.

e.g.

from matplotlib import pyplot as plt

fig, axs = plt.subplots(3, 3)
axs[0, 0].set_yscale("log")
axs[0, 0].bar(0, 1)
axs[0, 0].set_title("log-then-bar")
axs[0, 1].bar(0, 1)
axs[0, 1].set_yscale("log")
axs[0, 1].set_title("bar-then-log")
axs[0, 2].bar(0, 1, log=True)
axs[0, 2].set_title("bar(log=True)")

axs[1, 0].set_yscale("log")
axs[1, 0].hist(1, 1, histtype="step")
axs[1, 0].set_title("log-then-hist(step)")
axs[1, 1].hist(1, 1, histtype="step")
axs[1, 1].set_yscale("log")
axs[1, 1].set_title("hist(step)-then-log")
axs[1, 2].hist(1, 1, histtype="step", log=True)
axs[1, 2].set_title("hist(step, log=True)")

axs[2, 0].set_yscale("log")
axs[2, 0].hist(1, 1, histtype="stepfilled")
axs[2, 0].set_title("log-then-hist(stepfilled)")
axs[2, 1].hist(1, 1, histtype="stepfilled")
axs[2, 1].set_yscale("log")
axs[2, 1].set_title("hist(stepfilled)-then-log")
axs[2, 2].hist(1, 1, histtype="stepfilled", log=True)
axs[2, 2].set_title("hist(stepfilled, log=True)")

plt.show()

This previously gave
old

This PR makes the all rows always use the "top right/bottom left" behavior. Because hist(histtype="bar") (the default) simply calls bar(), this PR also makes the behavior of hist() more consistent.

The deleted tests are https://github.com/matplotlib/matplotlib/blob/v3.1.0/lib/matplotlib/tests/baseline_images/test_axes/hist_steplog.png, which is now
hist_steplog
(the lower margin is much more reasonable IMO) and #4608 (now both histograms go to 1e-2 -- one because that's what's passed as bottom, the other one because it goes basically to minus infinity but relies on the other's sticky margin).

Closes #4621 (which is essentially the same as the issue demo'ed above).
Closes #14981.

PR Summary

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

@anntzer anntzer changed the title Make logscale bar autolimits more consistents. Make logscale bar/hist autolimits more consistents. Jun 24, 2019
@anntzer anntzer force-pushed the barlog branch 2 times, most recently from 85e814f to 7f80dab Compare June 24, 2019 10:08
@anntzer anntzer added this to the v3.2.0 milestone Jul 18, 2019
The bottom limit of log-scaled bar/hist plots now defaults to applying
normal margins (possibly with null limits expansion) to the data limits,
rather than being hardcoded to 1/log_base.  See changelog.

Delete two tests that asserted that the lower limit was at 1/log_base.
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 5, 2019
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.
Projects
None yet
4 participants