Can't pickle matplotlib figure: error "Can't pickle 'tkapp' object"
<p>I'm trying to save a matplotlib.pyplot figure using <code>Pickle</code>.</p>

<p>However, I get the following error:</p>

<pre><code>`pickle.PicklingError: Can't pickle 'tkapp' object: &lt;tkapp object at 0x061047B8&gt;
</code></pre>

<p>I've read some other posts regarding problems with Pickle, but I've not been able to resolve my issue.</p>

<p>Please note I'm using <code>python 2.7.11</code> and <code>Matplotlib 1.5.1</code>.</p>

<p>Here is what the code looks like:</p>

<pre><code>import matplotlib.pyplot as plt
from scipy.misc import imread
import pickle

plt.figure()
plt.pot(x,y,label='one')
ax = plt.gca()
img = imread('C:/theview.jpg')
ax.imshow(img, cmap='gray')
ax.invert_yaxis()
legend = plt.legend(numpoints=1)
legend.draggable()
pickle.dump(ax, file(saveFigureAs,'wb')
</code></pre>