views:

602

answers:

2

Hi,

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://matplotlib.sourceforge.net/examples/api/unicode_minus.html

I run it, get no error, but the picture does not show up. In Linux Ubuntu I get it.

Do you know what could be wrong here?

Thanks

+1  A: 

When you try

plt.savefig('myfilename.png')

instead of

plt.show()

does that save the correct image named myfilename.png in the current path?

ChristopheD
Also: this suggests (for the 'not showing up' part) that you may need to have a matplotlibrc file (search for it first) and change the backend to tkAgg: http://newmediaandcapitalmarkets.org/component/content/article/68-how-i-got-matplotlib-working-on-my-macbook.html . Which python are you using?
ChristopheD
+4  A: 

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()))
sharth
now it works, thanks a lot!
Werner