8000 Crash when using zoom tools on a plot: AutoMinorLocator after MultipleLocator gives "ValueError: Need at least two major ticks to find minor tick locations" · Issue #807 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Crash when using zoom tools on a plot: AutoMinorLocator after MultipleLocator gives "ValueError: Need at least two major ticks to find minor tick locations" #807
Closed
@cgra

Description

@cgra

Run the following code and then zoom in with the zoom-box tool or the cross and right-click drag to zoom in.

from pylab import *
from matplotlib.ticker import MultipleLocator, AutoMinorLocator
plot([0,3],[0,2.2])
ax = gca()
ax.xaxis.set_major_locator(MultipleLocator(0.5))
ax.xaxis.set_minor_locator(AutoMinorLocator(2))
show()

Once MultipleLocator has been called, the auto-reassigning of tick spacing when zooming (either with the zoom box or the cross and right-click drag) does not happen, and then AutoMinorLocator gives the following error because it has "majorstep = majorlocs[1] - majorlocs[0]" and majorlocs has less than 2 elements when zoomed in that far.
"ValueError: Need at least two major ticks to find minor tick locations
( File "/usr/lib/pymodules/python2.7/matplotlib/ticker.py", line 1528, in call )"

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0