Use agg to plot graphs