python matplotlib Agg vs. interactive plotting and tight_layout
matplotlib, plot, python
Solution
The workaround, given by @FilipeCorreia in a comment, is to remove `mpl.use('Agg')`, and use `fig.set_tight_layout(True)` instead of `fig.tight_layout()`.
Problem
If I use the `Agg` backend, I'm unable to keep image windows open with `show()` (regardless of `block=True` or not)---they just close virtually immediately. If I don't use `Agg`, then I get the warning: `/Library/Python/2.7/site-packages/matplotlib-1.2.0-py2.7-macosx-10.8-intel.egg/matplotlib/tight_layout.py:225: UserWarning: tight_layout : falling back to Agg renderer warnings.warn("tight_layout : falling back to Agg renderer")` Sample code: ``` import matplotlib as mpl mpl.use('Agg') # With this line = figure disappears; without this line = warning import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np fig = plt.figure() ax = fig.add_subplot(111) mu, sigma = 0, 0.5 x = np.linspace(-3, 3, 100) plt.plot(x, mlab.normpdf(x, mu, sigma)) fig.tight_layout() plt.show() ``` Is there a different backend or methodology I should be using?