With python matplotlib module, we can use pylab.savefig() function to save figures. However it seems that this function can't be used to save figures in .fig format. The .fig format is matlab figure format.
With .fig format, we can adjust/modify the figures, that is why I want to save figures into .fig format.
So are there any ways to save figures in .fig format with python matplotlib?
You can pickle a figure to disk like this
import matplotlib.pyplot as plt
import numpy as np
import pickle
# Plot
fig_object = plt.figure()
x = np.linspace(0,3*np.pi)
y = np.sin(x)
plt.plot(x,y)
# Save to disk
pickle.dump(fig_object,open('sinus.pickle','wb'))
And then load it from disk and display:
fig_object = pickle.load(open('sinus.pickle','rb'))
fig_object.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With