Skip to content

LogLocator ignores numticks without axis #11518

Closed as not planned
Closed as not planned

Description

@mwaskom

Bug report

Bug summary

It does not seem possible to use LogLocator to generate a specific number of log-spaced tick locations without a live axis.

Code for reproduction

import matplotlib as mpl
ticker = mpl.ticker.LogLocator(numticks=2)
ticker.tick_values(1, 10)

array([ 0.1, 1. , 10. , 100. ])

Expected outcome

array([ 1. , 10. , ])

Matplotlib version

  • Matplotlib version: 2.2.2
  • Python version: 3.6

Activity

  1. mwaskom commented on Jun 27, 2018

    @mwaskom
    Author

    For context about my expectations, here's how this works on an axis:

    import matplotlib.pyplot as plt
    f, ax = plt.subplots(figsize=(6, 4))
    ax.plot(np.logspace(1, 4, 10))
    ax.set_yscale("log")
    ax.yaxis.set_major_locator(mpl.ticker.LogLocator(numticks=2))

    image

  2. WeatherGod commented on Jun 27, 2018

    @WeatherGod
    Member
  3. mwaskom commented on Jun 27, 2018

    @mwaskom
    Author

    Ah, I think that's right:

    import matplotlib.pyplot as plt
    f, ax = plt.subplots(figsize=(6, 4))
    ax.plot(np.logspace(1, 4, 10))
    ax.set_yscale("log")
    ax.yaxis.set_major_locator(mpl.ticker.LogLocator(numticks=2))
    ax.get_yticks()
    array([  1.00000000e-02,   1.00000000e+00,   1.00000000e+02,
             1.00000000e+04,   1.00000000e+06,   1.00000000e+08])
    

    So I think the match between the appearance and the numticks parameter here was serendipitous.

    It's still very confusing, however, how little (if any) influence numticks seems to have on the number of positions that the locator generates...

  4. github-actions commented on May 8, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions