Skip to content Skip to sidebar Skip to footer

How To "switch To One Of The Agg Backends"?

I have the same problem as this problem, namely that when using matplotlib and networkx on Mac OS X 10.8.5, labels are not displayed. The solution in that thread is 'Switching to

Solution 1:

This should work (note that use needs to be called before pyplot is imported):

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplotas plt

There are more details in other questions if you search for "Agg" or "backend", e.g. this one.

Edit: Sorry, maybe I didn't understand exactly what you are trying to do. As sebix points out, Agg is a backend for plotting to a file (i.e. non-interactive plots), and if you want an interactive plot to appear on the screen, then use one of the interactive backends. e.g. Qt4Agg (note this needs PyQt4).

Solution 2:

You can also use

plt.switch_backend('Qt4Agg')

Post a Comment for "How To "switch To One Of The Agg Backends"?"