8000 [Bug]: _raw_ticker() istep · Issue #27603 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: _raw_ticker() istep #27603
Closed
@BertJorissen

Description

@BertJorissen

Bug summary

Before 3.8.0, in matplotlib.ticker.MaxNLocator._raw_ticker(), there was a for-loop going over different possibilities that breaks out of the loop if a suitable condition was found, now it returns an empty list and fails.

Code for reproduction

# set up
import matplotlib as mpl
import numpy as np
mpl.rcParams['axes.autolimit_mode'] = 'round_numbers'
mnl = mpl.ticker.MaxNLocator()
mnl._nbins = 1
mnl._extended_steps = np.array([0.1,0.2,0.5,1.,2.,5.,10. ,20.])

# function that causes the bug to appear
mnl._raw_ticks(-9.4, 18.9)

Actual outcome

IndexError: index 0 is out of bounds for axis 0 with size 0

Expected outcome

not failing, it should just break at line 2135

Additional information

https://github.com/matplotlib/matplotlib/blob/eb02b108ea181930ab37717c75e07ba792e01f1d/lib/matplotlib/ticker.py#L2109C7-L2109C8

Before 3.8.0, in matplotlib.ticker.MaxNLocator._raw_ticker(), there was a for-loop going over different possibilities that breaks out of the loop if a suitable condition was found, now it returns an empty list. Then, it searches for values in this list. As this list is empty, it gives an error.

This worked before 3.8.0. I'm currently preparing a new release of my own package 'pybinding', and I noticed that this error appeared in the newer versions (available on test.pypi.org).
The error originates from calling the function ax.autoscale_view() or calling other functions from Matplotlib that in turn call ax.autoscale_view().
I just discovered this, and I can probably work around this issue, but I though to inform you to know if this is wanted behavior.

Operating system

No response

Matplotlib Version

3.8.0

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0