FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`ax.get_xaxis().get_minorticklabels()` always returns list of empty strings · Issue #13968 · matplotlib/matplotlib · GitHub

Repository navigation

ax.get_xaxis().get_minorticklabels() always returns list of empty strings #13968

Closed

Description

Bug report

Bug summary

ax.get_xaxis().get_minorticklabels() always returns list of empty strings.

Code for reproduction

import matplotlib
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

ax.set_xscale('log')
ax.set_yscale('log')

ax.set_xlim([2e-2, 2e-1])
ax.set_ylim([2e+1, 2e+3])

ax.plot([0.02, 0.1, 0.2], [20, 1000, 2000])

ax.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
ax.get_xaxis().set_minor_formatter(matplotlib.ticker.ScalarFormatter())

fig.canvas.draw()

print([item.get_text() for item in ax.get_xaxis().get_minorticklabels()])

plt.show()

Actual outcome

['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']

Expected outcome

['0.00', '0.00', '0.00', '0.01', '0.01', '0.01', '0.01', '0.01', '0.02', '0.03', '0.04', '0.05', '0.06', '0.07', '0.08', '0.09', '0.20', '0.30', '0.40', '0.50', '0.60', '0.70', '0.80', '0.90', '2.00', '3.00', '4.00', '5.00', '6.00', '7.00', '8.00', '9.00', '20.00', '30.00', '40.00', '50.00', '60.00', '70.00', '80.00', '90.00']

Matplotlib version

  • Operating system: macOS Mojave 10.14.4
  • Matplotlib version: 3.0.3
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 3.7.3

Python installed using homebrew, matplotlib using pip.

Activity

  1. changed the title [-]`ax.get_xaxis().get_minorticklabels()` always removes list of empty strings[/-] [+]`ax.get_xaxis().get_minorticklabels()` always returns list of empty strings[/+] on Apr 15, 2019
  2. ImportanceOfBeingErnest commented on Apr 15, 2019

    Member

    Do you get the same with TkAgg backend? I.e. import matplotlib; matplotlib.use("TkAgg")

  3. tdegeus commented on Apr 15, 2019

    Author

    @ImportanceOfBeingErnest I get an uncaught exception of type NSException when using matplotlib.use("TkAgg")?!?!

  4. ImportanceOfBeingErnest commented on Apr 15, 2019

    Member

    Ok, that's unfortunate, but is unrelated (you may not have tk inter installed). Would "Qt5Agg" work instead? I'm trying to find out if this is backend dependent, because I cannot reproduce (and don't have a Mac).

  5. tdegeus commented on Apr 15, 2019

    Author

    @ImportanceOfBeingErnest No such luck. I can say that a colleague on a mac can reproduce this problem (in his case installation through macports)

  6. jklymak commented on Apr 15, 2019

    Member

    That is very strange. Indeed toggling matplotlib.use('MacOSX') and matplotlib.use('Qt5Agg') give the bug and the expected result respectively.

    If you do:

    print([item.get_text() for item in ax.get_xaxis().get_minorticklabels()])
    plt.show()
    print([item.get_text() for item in ax.get_xaxis().get_minorticklabels()])

    and close the window you get the right answer...

    ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
    ['0.00', '0.00', '0.00', '0.01', '0.01', '0.01', '0.01', '0.01', '0.02', '0.03', '0.04', '0.05', '0.06', '0.07', '0.08', '0.09', '0.20', '0.30', '0.40', '0.50', '0.60', '0.70', '0.80', '0.90', '2.00', '3.00', '4.00', '5.00', '6.00', '7.00', '8.00', '9.00', '20.00', '30.00', '40.00', '50.00', '60.00', '70.00', '80.00', '90.00']
    
  7. tdegeus commented on Apr 16, 2019

    Author

    I can reproduce that after plt.show the output is what it should be.

  8. added this to the v3.5.1 milestone on Nov 30, 2021
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL