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

BUG: endless loop with MaxNLocator integer kwarg and short axis #6849

Closed
efiring opened this issue Jul 28, 2016 · 5 comments
Closed

BUG: endless loop with MaxNLocator integer kwarg and short axis #6849

efiring opened this issue Jul 28, 2016 · 5 comments
Assignees
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@efiring
Copy link
Member

efiring commented Jul 28, 2016

In v2.x:

fig, ax = plt.subplots()
ax.plot([0.5, 1.5], [1, 2])
ax.locator_params(axis='x', integer=True)

This leads to an infinite loop in MaxNLocator._raw_ticks.

@efiring efiring added this to the 2.0 (style change major release) milestone Jul 28, 2016
@efiring
Copy link
Member Author

efiring commented Jul 28, 2016

The choices are to allow fewer than 2 ticks (as few as zero) in the integer case, or to expand the viewLim as needed to include at least 2 ticks.

@tacaswell
Copy link
Member

This is tough. Expanding the viewLim is bad because we could be over-riding user input, no ticks is bad because that is a useless plot.

@afvincent
Copy link
Contributor

Is there a way to warn the user in the case he/she asked for integer ticks but the viewLim is too narrow for displaying any tick? Because one solution might be to opt for allowing fewer than 2 ticks in the integer case, and throw a warning if in the end there is 0 tick plotted. That way, one does not override any user input and the user is aware that he might have asked for a “useless” plot (meaning a plot with integer tick positions but with no integer values plotted, for example).

@efiring
Copy link
Member Author

efiring commented Jul 28, 2016

There is one more alternative: document the 'integer' kwarg as a preference that will be overridden if it would lead to fewer than 2 ticks. I think this is the way to go.

@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 1, 2016
@efiring efiring self-assigned this Aug 1, 2016
tacaswell added a commit that referenced this issue Aug 22, 2016
ENH: Rework MaxNLocator, eliminating infinite loop; closes #6849
tacaswell added a commit that referenced this issue Aug 22, 2016
ENH: Rework MaxNLocator, eliminating infinite loop; closes #6849
@tacaswell
Copy link
Member

backported to v2.x as 9982e40

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
Development

No branches or pull requests

3 participants