python matplotlib save graph as data file -
i want create python script zooms in , out of matplotlib graphs along horizontal axis. plot set of horizontal bar graphs.
i want make able take generic matplotlib graph.
i not want load image , zoom that, want zoom graph along horizontal axis. (i know how this)
is there way can save , load created graph data file or there object can save , load later?
(typically, creating graph , displaying matplotlib plt.show, graph creation takes time , not want recreate graph every time want display it)
you can use pickle package saving axes , load back.
save plot pickle
file:
import pickle import matplotlib.pyplot plt ax = plt.plot([1,2,5,10]) pickle.dump(ax, open("plot.pickle", "wb"))
and load back:
import pickle import matplotlib.pyplot plt ax = pickle.load(open("plot.pickle", "rb")) plt.show()
Comments
Post a Comment