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

get_ticklabels returns '' in ipython/python interpreter · Issue #6638 · matplotlib/matplotlib · GitHub

Repository navigation

get_ticklabels returns '' in ipython/python interpreter #6638

Closed

Description

ax.get_xticklabels & ax.get_yticklabels is returning a list of empty strings when I run the code via script/ipython interpreter, but works as expected (returns list of ticklabels) when called in ipython notebook. This makes me think it's a backend bug, but I'm mystified.

Env:

Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec  7 2015, 11:24:55) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin

matplotlib version:

  • 1.5.1 (installed in different anaconda env to verify not a beta bug)
  • 2.0.0b1.post1730.dev0+gfdce976 (last pulled in a few hours ago)

This will reproduce it: (I use agg here, but MacOSX is exhibiting the same behavior)

import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot([1,2,3])
print(list(l.get_text() for l in ax.get_xticklabels()))
print(list(l.get_text() for l in ax.get_yticklabels()))

Both print statements yield ['', '', '', '', ''] when they should be [0, 1, 2] & [1, 2, 3]

Activity

  1. changed the title [-]get_ticklabels returns "" in ipython/python interpreter[/-] [+]get_ticklabels returns '' in ipython/python interpreter[/+] on Jun 24, 2016
  2. Tillsten commented on Jun 24, 2016

    Contributor

    Afaik the ticks will be popluated at draw time.

  3. story645 commented on Jun 24, 2016

    MemberAuthor
    import matplotlib
    matplotlib.use('agg')
    import matplotlib.pyplot as plt
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    ax.plot([1,2,3])
    plt.draw()

    works, but still won't work with 'MacOSX' backend,

  4. partizanos commented on Oct 1, 2020

    @story645
    You can use instead
    [i.get_text() for i in plt.xticks()[1]]

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


      Back | FazBrowse Home | New Git URL