Skip to content

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

Closed as not planned

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

Activity

  1. dstansby commented on Nov 30, 2022

    @dstansby
    MemberAuthor

    To document where I've got with this:

  2. dstansby commented on Dec 1, 2022

    @dstansby
    MemberAuthor

    Sigh, sorry for the noise, I realise that get_ticklocs() is documented to not return ticks within bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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