Skip to content

v2.2.3 matplotlib.pyplot.plot() creates empty plot. savefig() works as expected.  #12074

Closed

Description

@mmenschig

Bug report

Bug summary

When using the latest stable version of matplotlib (v2.2.3), running plt.plot() only displays a blank figure, regardless of chosen backend. However, the .savefig() method correctly stores an image of the plot.

Switching to an older version (2.0.2) resolves the issue.

Code for reproduction

import matplotlib as mpl
mpl.use("TKAgg")

import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.savefig('testfigure.png', dpi=100)
plt.show(block=True)

Actual outcome

Image

No code errors.

Expected outcome

Image

Matplotlib version
2.2.3 - works on 2.0.2

  • Operating system: MacOS Mojave (10.14 Beta (18A384a))
  • Matplotlib version: 2.2.3
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.7
  • Jupyter version (if applicable): N/A
  • Other libraries: N/A

Installed via pip install matplotlib

Activity

  1. mmenschig commented on Sep 9, 2018

    @mmenschig
    Author

    Further testing shows that the bug does not reproduce using versions 2.1.2.

  2. jklymak commented on Sep 9, 2018

    @jklymak
    Member

    I cannot reproduce using master or v2.2.3. My guess would be pip didn't install something for you properly...

  3. mmenschig commented on Sep 9, 2018

    @mmenschig
    Author

    @jklymak running macOS?

  4. jklymak commented on Sep 9, 2018

    @jklymak
    Member

    Yes, but I install via conda.

  5. mmenschig commented on Sep 9, 2018

    @mmenschig
    Author

    @jklymak Interesting. Just installed anaconda (I don't usually use it, so may not keep it) and created a new env and installed matplotlib, ran the code and voilà, the figure shows the data as expected.

    Doesn't seem to be an issue with matplotlib at all after all. Any thoughts on what to try next? Think this is an issue with pip?

  6. phobson commented on Sep 10, 2018

    @phobson
    Member

    How fresh is your pip-based environment that produces this issue? Can you provide steps to recreate the environment?

  7. tacaswell commented on Sep 10, 2018

    @tacaswell
    Member

    This may be an issue with tk. We changed details about how exactly the c-extension we need for tk is built / linked in 2.2 (to support pypy!).

    What version of osx? This may also be an issue with the wheels and conflicts between the tk you have, the tk they were built with, and the version of OSX they were built with vs the version of OSX you have.

  8. mmenschig commented on Sep 10, 2018

    @mmenschig
    Author

    The issue appears with macOS Mojave (10.14 Beta (18A384a))
    Just tested this with macOS Sierra (10.12.6) and the figure is displayed correctly.

  9. tacaswell commented on Sep 10, 2018

    @tacaswell
    Member

    If you have a beta OSX, can you direct this issue towards them?

  10. jklymak commented on Sep 10, 2018

    @jklymak
    Member

    Closing as I don't think this is us. I think either Tk needs to be updated or there is an issue w/ OSX

  11. mmenschig commented on Sep 17, 2018

    @mmenschig
    Author

    Thank you @jklymak

    I'll be revisiting this issue when the current beta version of macOS gets released and provide an update then.

  12. shamoons commented on Feb 12, 2019

    @shamoons

    Can we reopen? I'm having this issue with 10.14.3

  13. jklymak commented on Feb 12, 2019

    @jklymak
    Member

    @shamoons can you re-open a full issue, including versions, what you did to install, and what you have tried to fix the problem. As noted above, this is usually an installation problem with an old library lying around from a previous install somehow not being cleared out. Thanks...

  14. DaoSYi commented on Feb 14, 2019

    @DaoSYi

    The issue appears with macOS Mojave (10.14 Beta (18A384a))
    Just tested this with macOS Sierra (10.12.6) and the figure is displayed correctly.

    I have the same problem.

    • Matplotlib version:3.0.2
  15. 35 remaining items

  16. janosh commented on Jun 26, 2019

    @janosh

    This has been bugging me for quite a while now. From skimming this issue, it seems it's still unclear where this problem originates?

  17. efiring commented on Jun 26, 2019

    @efiring
    Member

    Yes, it's unclear. It would be great to have someone with expertise in all 3 of Tk, OSX, and mpl to track down the problem and solve it.

  18. ocefpaf commented on Jun 26, 2019

    @ocefpaf
    Contributor

    @ocefpaf it looks like there might be something very fiddly with tk versions and builds for OSX in conda-forge.

    Opened conda-forge/tk-feedstock#36 to track this.

  19. tacaswell commented on Aug 19, 2019

    @tacaswell
    Member

    This looks like it is issues with how tk is built and its interaction with OSX , closing as there is nothing we can do about it at the Matplotlib level.

  20. removed this from the v2.2.5 milestone on Aug 19, 2019
  21. jklymak commented on Aug 28, 2019

    @jklymak
    Member

    I'm going to re-open until conda rebuilds so folks searching the issues and not at closed issues will see that this is an understood issue and an upstream problem....

  22. added a commit that references this issue on Nov 5, 2019
  23. vboikotriller commented on Feb 9, 2021

    @vboikotriller

    I have the same issue on Linux Debian.
    matplotlib==3.3.4
    Pillow==8.1.0

    python3-tk 3.9.1-2

    """
    import matplotlib.pyplot as plt
    import numpy as np
    plt.title("Title")
    plt.plot(np.linspace(-1, 1, 50), np.linspace(-2, 2, 50))
    """

    If I take title out, it works. Why matplotlib can't display titles ?

  24. jklymak commented on Feb 9, 2021

    @jklymak
    Member

    If you have checked your install please open a new issue.

  25. dstansby commented on Jan 2, 2023

    @dstansby
    Member

    Using tk 8.6.12 he1e0b03_0 conda-forge (the latest version) this seems to be working fine for me, so I'm going to close this. If this is still an issue for anyone please comment and I will re-open!

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