Repository navigation
DOC: MaxNLocator and contour/contourf doc update (replaces #16428) - #16534
Merged
efiring merged 1 commit intoMar 2, 2020
Merged
Conversation
6 tasks
tacaswell
reviewed
Feb 16, 2020
tacaswell
requested changes
Feb 16, 2020
tacaswell
left a comment
Member
There was a problem hiding this comment.
I do not think this documentation change is correct, and if it is it is showing a major bug in the locator code.
Per #16428 (comment) I think the N needs to be qualified to be within the view limit and that it make return additional ticks outside of the view limit.
efiring
reviewed
Feb 16, 2020
Member
|
The following test shows that it selects no more than N ticks within the view limits, inclusive on the left and exclusive on the right. It has to provide up to 2 more so that it can be used for autoscaling in "classic" mode. import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
Ntargets = np.arange(3, 20)
vmins = np.linspace(1, 10, 50)
spans = np.linspace(1, 10, 50)
shape = len(Ntargets), len(vmins), len(spans)
nticks_inside = np.zeros(shape, dtype=int)
nticks = np.zeros(shape, dtype=int)
for i, N in enumerate(Ntargets):
locator = MaxNLocator(N)
for j, vmin in enumerate(vmins):
for k, span in enumerate(spans):
vmax = vmin + span
ticks = locator.tick_values(vmin, vmax)
nticks[i, j, k] = len(ticks)
clipped = ticks[(ticks < vmax) & (ticks >= vmin)]
nticks_inside[i, j, k] = len(clipped)
print(Ntargets - nticks_inside.max(axis=-1).max(axis=-1))Run it: |
Contributor
Author
|
@tacaswell and @efiring Thanks for (patiently) explaining the point about the view limits. Pushed a change as suggested. |
efiring
approved these changes
Mar 2, 2020
Member
|
Thank you, @pharshalp. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
closes #12729
I messed my github matplotlib repo settings (and not github doesn't recognize my old branch... it says
pharshalp wants to merge 1 commit into matplotlib:master from **unknown repository**) so closed the older PR and recreated it here.Sorry for the noise!
Please see #16428 the reviewers' comments, suggestions and discussion.
MaxNLocator's docs were incorrect (please see the details described in #12729).Here is a numerical experiment that I ran to determine the difference between the number of tick locations returned by
MaxNLocatorand the argumentnbins.It turns out (as was shown in the original issue) that
MaxNLocatorreturns at mostnbins+2tick locations (nbins+1intervals).Since contour/contourf uses MaxNLocator (as pointed out in the original issue) updated their docs as well.
PR Checklist