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
I can verify this on my end as well. To fix, here's what I did
sudo port install py25-matplotlib +cairo+gtk2
sudo port install py26-matplotlib +cairo+gtk2
Also, we need to change the default backend to a GUI based one.
Edit the file ~/.matplotlib/matplotlibrc
, and add:
backend: GTKCairo
Also, you can try the following, which may allow you to not need the GTK or Cairo backends.
Edit ~/.matplotlib/matplotlibrc
and add:
backend: MacOSX
With the port with those variants installed, this works as well, but it doesn't require X11.
By the way, the error that I saw was the following:
/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/__init__.py:41: UserWarning:
Your currently selected backend, 'Agg' does not support show().
Please select a GUI backend in your matplotlibrc file ('/Users/wlynch/.matplotlib/matplotlibrc') or with matplotlib.use()
(backend, matplotlib.matplotlib_fname()))
sudo port install py37-matplotlib +cairo+gtk3
~/.matplotlib/matplotlibrc used
backend: MacOSX
Seemed to work on MacOS Mojave 10.14.4 with python 3.7 on the unicode_minus.py example above.
This is what worked for me. I just changed the import of Matplotlib
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
I only had python 2.5 and I did not want to install python 2.6 on my mac. So I used different procedure mentioned in the following link to solve this problem:
http://www.gtkforums.com/viewtopic.php?f=3&t=54928
What that one actually needs is the following steps:
1) Searching where is the directory "pygtk-2.0.pc" and locate it. For example mine was located in the following directory:
/opt/local/lib/pkgconfig
2) Adding the path information to envirement variable. For example:
PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
export PKG_CONFIG_PATH
3) Download the configuration information file "matplotlibrc" from matplotlib website http://matplotlib.sourceforge.net/_static/matplotlibrc
4) Change backend to MacOSX in the file and save it
5) Copy the file to directory .matplotlib You can locate the directory in python by the following command:
import matplotlib
matplotlib.get_configdir()
When you try
plt.savefig('myfilename.png')
instead of
plt.show()
does that save the correct image named myfilename.png
in the current path?
Do the following if anyone is using spyder.
1.) Start Spyder 2.3.5.2 from Anaconda Launcher 2.) Go to preferences -> IPython console -> Graphics -> Backend: changed it to "Automatic" 3.) Select "Apply" and close preferences 3.) Restart IPython kernel 4.) Create simple graphic like