Skip to content

[Bug]: get_ticklocs() returns ticks outside axis limits for log scale #24572

Closed as not planned
@dstansby

Description

@dstansby

Bug summary

get_ticklocs() is returning ticks outside the axis limits, when the scale is set to log.

I discovered this when writing some tests for LogLocator in #24436.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax.set_xscale('log')
ax.set_xlim(1, 99)

fig.canvas.draw()
print(ax.xaxis.get_ticklocs())
# [1.e-01 1.e+00 1.e+01 1.e+02 1.e+03]
plt.show()

Actual outcome

Prints [1.e-01 1.e+00 1.e+01 1.e+02 1.e+03], but plots this:

log_ticks

Note that the only ticks shown on this graph are 1 and 10.

Expected outcome

ax.xaxis.get_ticklocs() returns only tick locations present on the axis.

Additional information

No response

Operating system

No response

Matplotlib Version

3.7.0.dev656+g79807c34ad.d20221130

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions