1

I have an interactive matplotlib figure that I would like to be able to access post generation and modify. Specifically I have a slider that modifies the line data in a subplot, and i would like to be able to go back and interact with this slider at any time after the image is originally created. From what I read here, pickle should be able to do this for me. However, when I try to load my .pickle file the script runs and nothing opens. Any thoughts?

For creating the file:

plt.show()
pickle.dump(fig, open(r"C:/users/.../file.pickle", 'wb'))

For reading the file:

ax = pickle.load(open(r'C:/Users/.../file.pickle', 'rb'))

plt.show()
Community
  • 1
  • 1
Grr
  • 15,553
  • 7
  • 65
  • 85

1 Answers1

2

Calling plt.show() before pickling destroys the figure. You need to pickle the figure first. Then things work for me.

Christoph
  • 1,537
  • 13
  • 19
  • Ok so that worked for being able to bring the interactive figure back up. Now I have another question. My image has sliders which can modify the line functions plotted on the subplots. Is there a way in which you can recreate the functionality of these sliders after closing the original interactive image. My instinct says no as the data that these sliders access would no longer be available, but a man can dream. So is that something that is possible or not? – Grr Jan 20 '16 at 20:23
  • @Grr I don't know. I guess this warrants a new question. But maybe just storing the data and recreating the plot would be better? – Christoph Jan 20 '16 at 22:20