I solve it thanks
HI Ptrblck,
I need to save my results which can be graphs or figures, and reload them again to change title, xlabel or color of the graph ā¦ Would you please tell me how I can save my results (figures, or graphs) to make it possible to reload them and change title size xlabel or ylabel ā¦
If Iām not mistaken, matplotlib
has (experimental) pickle
support, so that you could store and load the figure and manipulate it as you wish.
Here is a small example:
fig = plt.figure()
ax = fig.add_subplot(111)
plt.plot(np.random.randn(100))
ax.set_title('randn')
fig.show()
with open('fig.pickle', 'wb') as f:
pickle.dump(fig, f)
# in another script
with open('fig.pickle', 'rb') as f:
fig = pickle.load(f)
fig.axes[0].set_title('new_title')
fig.show()
However, it might be easier to store the data instead of the figure and just recreate the plot (with your new changes).