do not import pylab unless necessary, so that matplotlib.use('Agg') can be called later