Answers for "matplotlib save as numpy array"

0

save numpy array

np.save("sim1.npy", sim)
Posted by: Guest on May-03-2021
0

save matplotlib figure as array

fig = plt.figure()
ax= fig.add_subplot(111)

plt.plot(your_data)

# turn antialiasing off for lines
plt.setp([ax.get_xticklines() + ax.get_yticklines() + ax.get_xgridlines() + ax.get_ygridlines()],antialiased=False)
# turn antialiasing off for text
mpl.rcParams['text.antialiased']=False

fig.canvas.draw()

array = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
array = data.reshape(fig.canvas.get_width_height()[::-1] + (3,))
Posted by: Guest on May-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language