Showing posts with label matplotlib. Show all posts
Showing posts with label matplotlib. Show all posts

2008-01-16

DISPLAY error matplotlib

When error occur about this "$DISPLAY not set" when you run python code that use matplotlib this happened because your matplotlib backend is set to FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg they required a GUI that why error occur.

To solve this you must specific other backend that not required GUI (Agg, Cairo, PS, PDF or SVG) when use matplotlib like this
  • In code
 import matplotlib
matplotlib.use('Agg')
  • In command line use -d option
python subplot_demo.py -dAgg

Remember when call savefig('filename') don't give it extension this will handle by backend that you specific e.g Agg will create file filename.png

source from --> http://matplotlib.sourceforge.net/backends.html

2007-11-20

How to set font properties in matplotlib create graph

1. Create font dict like this
- font = { 'fontname':'Tahoma', 'fontsize':16 }
2. When you want to change font for example in title use like this
- matplotlib.pylab.title(u'some text', **font)