Matplotlib plots not showing up in Mac OSX?

后端 未结 13 560
梦如初夏
梦如初夏 2020-12-12 14:16

I am running Mac OSX 10.5.8. I installed matplotlib using macports. I get some examples from the matplotlib gallery like this one, without modification:

http://matpl

相关标签:
13条回答
  • 2020-12-12 14:39

    Mac comes with its own python (read from here, which is not the best), I would suggest just a clean install of some Python 3.7 or so along with Anaconda and then introduce them as interpreters to PyCharm. anything will work fine and you wont need to add ad-hoc solutions like "backend: MacOSX" or so.

    0 讨论(0)
  • 2020-12-12 14:40

    After the plot simply add -

    plt.show()

    The reason this works is to do with interactive vs non-interactive mode. If the backend is opened in non-interactive mode, plt.show() is required at the end of the code chunk. You can check the status by calling plt.isinteractive() and toggle the status using plt.ion() and plt.ioff()

    0 讨论(0)
  • 2020-12-12 14:41

    I wanna share this workable solution for me,

    import matplotlib
    import platform
    if platform.system() == 'Darwin':
        matplotlib.use('MacOSX')
    
    0 讨论(0)
  • 2020-12-12 14:43

    This is what worked for me:

    brew install pkg-config
    brew link pkg-config
    brew install pygtk
    brew install freetype
    brew install libpng
    
    sudo ln -s /usr/local/Cellar/freetype/*/lib/pkgconfig/freetype2.pc /usr/local/lib/pkgconfig/freetype2.pc
    
    git clone git@github.com:matplotlib/matplotlib.git
    cd matplotlib
    python setup.py build
    python setup.py install
    

    References:

    http://blog.caoyuan.me/2012/08/matplotlib-error-mac-os-x/ http://matplotlib.org/faq/installing_faq.html#install-from-git http://www.tapir.caltech.edu/~dtsang/python.html

    0 讨论(0)
  • 2020-12-12 14:50

    I had the same problem, even I could see how a new application window was created and immediately disappeared.

    Simple solution - just check if you have

    plt.show()
    

    after the plot

    0 讨论(0)
  • 2020-12-12 14:50

    just to add a note,

    The matplotlibrc file was not present on my system and I had to to download a copy from the matplotlib website. Future users may have to do the same.

    0 讨论(0)
提交回复
热议问题