Generating matplotlib graphs without a running X server


This question already has an answer here:


@Neil's answer is one (perfectly valid!) way of doing it, but you can also simply call matplotlib.use('Agg') before importing matplotlib.pyplot, and then continue as normal.


import matplotlib as mpl
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

You don't have to use the Agg backend, as well. The pdf, ps, svg, agg, cairo, and gdk backends can all be used without an X-server. However, only the Agg backend will be built by default (I think?), so there's a good chance that the other backends may not be enabled on your particular install.

Alternately, you can just set the backend parameter in your .matplotlibrc file to automatically have matplotlib.pyplot use the given renderer.

You need to use the matplotlib API directly rather than going through the pylab interface. There's a good example here:

Need Your Help

Schema changes not updating in Intellisense in SQL 2008 (SSMS)

sql-server sql-server-2008 intellisense ssms

I've notice an issue - it feels like a bug but I suspect a 'feature' - in SSMS in SQL Server 2008.

Why are methods in Ruby documentation preceded by a hash sign?

ruby documentation

This is something that has been bugging me for a while. When I see any Ruby method printed in text, it usually appears as: