Skip to content

Validate steps input to MaxNLocator #7578

Closed
@QuLogic

Description

@QuLogic

NOTE The following was actually incorrect as the steps input was invalid; thus this ticket has been modified slightly to note the fact that steps should be validated in some manner.

Differences in MaxNLocator between 2.0.0 and 1.5.3 may be minimized by ensuring steps is between 1 and 10 and the classic style is used.


I ran the Cartopy test suite against v2.0.0rc1 and there appear to be some changes in the result from MaxNLocator. The default style change page only references changes to AutoLocator and the API changes page mentions LinearScaleLocator. I don't see any obvious changes in the tests for MaxNLocator, so I guess this is a bug, or needs to be better documented.

Here is the result on 1.5.3:

python
>>> import matplotlib
>>> matplotlib.__version__
'1.5.3'
>>> from matplotlib.ticker import MaxNLocator
>>> degree_locator = MaxNLocator(nbins=9, steps=[1, 2, 3, 6, 15, 18])
>>> degree_locator.tick_values(-180, 180)
array([-180., -120.,  -60.,    0.,   60.,  120.,  180.])
>>> degree_locator.tick_values(-50000000.0, 50000000.0)
array([-60000000., -40000000., -20000000.,         0.,  20000000.,
        40000000.,  60000000.])
>>> degree_locator.tick_values(-61.2479231, 68.41835367)
array([-80., -60., -40., -20.,   0.,  20.,  40.,  60.,  80.])

and here is the result with v2.0.0rc1

python
>>> import matplotlib
>>> matplotlib.__version__
'2.0.0rc1'
>>> from matplotlib.ticker import MaxNLocator
>>> degree_locator = MaxNLocator(nbins=9, steps=[1, 2, 3, 6, 15, 18])
>>> degree_locator.tick_values(-180, 180)
array([-180., -120.,  -60.,    0.,   60.,  120.,  180.])
>>> degree_locator.tick_values(-50000000.0, 50000000.0)
array([-60000000., -45000000., -30000000., -15000000.,         0.,
        15000000.,  30000000.,  45000000.,  60000000.])
>>> degree_locator.tick_values(-61.2479231, 68.41835367)
array([-75., -60., -45., -30., -15.,   0.,  15.,  30.,  45.,  60.,  75.])
  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...): 2.0.0rc1, conda's 3.5.2, Linux
  • How did you install Matplotlib and Python (pip, anaconda, from source ...): from source
  • If possible please supply a Short, Self Contained, Correct, Example
    that demonstrates the issue i.e a small piece of code which reproduces the issue
    and can be run with out any other (or as few as possible) external dependencies.
  • If this is an image generation bug attach a screenshot demonstrating the issue.
  • If this is a regression (Used to work in an earlier version of Matplotlib), please
    note where it used to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions