Python matplotlib: how to automatically save numbers in .fig format?

With the python matplotlib module, we can use the pylab.savefig () function to save the numbers. However, it seems that this function cannot be used to save digits in .fig format. The .fig format is the shape format in Matlab format.

In the .fig format, we can configure / change the numbers, so I want to save the numbers in the .fig format.

So, are there any ways to save the numbers in .fig format using python matplotlib?

+4
source share
2 answers

You can saw a shape to a 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,file('sinus.pickle','w'))

And then load it from the disk and onto the screen:

fig_object = pickle.load(open('sinus.pickle','rb'))
fig_object.show()
+3
source

.fig, , - (eps). , Adobe Illustrator.

import matplotlib.pyplot as plt
.
.
.
plt.savefig("MyFigure.eps", format="eps")
0

Source: https://habr.com/ru/post/1536622/


All Articles