Skip to content
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

Allow constructing boxplots over multiple calls. #13444

Merged
merged 1 commit into from
Feb 18, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 15, 2019

Currently, calls to boxplot() set the axis limits, ticks, and ticklabels
assuming that nothing else, and in particular no other boxplot, will be
drawn on the axis; e.g., after

boxplot(np.random.rand(100), positions=[3])
boxplot(np.random.rand(100), positions=[5])

the xlims will be moved to hide the first boxplot, and even after
manually resetting the xlims, the tick at x=3 and its label will be gone
too.

Fix that to make boxplot a bit more cooperative with previous calls:
instead of forcefully setting the axis limits, just update the dataLim
and let autoscaling handle axis limits; also check whether the axis
already has a FixedLocator/FixedFormatter and if so, just append the new
tick locations and labels.

Also rename manage_xticks to manage_ticks (with deprecation), as the
direction it manages depends on the vert kwarg (discussed in #13435).

attn @phobson I guess.

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

Currently, calls to boxplot() set the axis limits, ticks, and ticklabels
assuming that nothing else, and in particular no other boxplot, will be
drawn on the axis; e.g., after

    boxplot(np.random.rand(100), positions=[3])
    boxplot(np.random.rand(100), positions=[5])

the xlims will be moved to hide the first boxplot, and even after
manually resetting the xlims, the tick at x=3 and its label will be gone
too.

Fix that to make boxplot a bit more cooperative with previous calls:
instead of forcefully setting the axis limits, just update the dataLim
and let autoscaling handle axis limits; also check whether the axis
already has a FixedLocator/FixedFormatter and if so, just append the new
tick locations and labels.

Also rename manage_xticks to manage_ticks (with deprecation), as the
direction it manages depends on the vert kwarg.
lib/matplotlib/axes/_axes.py Show resolved Hide resolved
Copy link
Member

@phobson phobson left a comment

Choose a reason for hiding this comment

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

Thanks @anntzer !

@phobson phobson merged commit b87182d into matplotlib:master Feb 18, 2019
@anntzer anntzer deleted the boxplot-multiple branch February 18, 2019 15:11
@QuLogic QuLogic added this to the v3.1.0 milestone Feb 18, 2019
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.

None yet

4 participants