I have some figures and axes saved to pickle files using:
pickle.dump((fig, ax), open('myplot.pickle', 'wb'))
I'm trying to load this later in a separate file, apply a new style file to it, and export it again:
plt.style.use("some_fancy_style")
fig, ax = pickle.load(open("myplot.pickle", "rb"))
fig.savefig("myplot_different_style.png")
But this only picks up a few settings related to savefig
from the style file. Is there a (relatively easy) way to recreate the plot so that axes/font/grid/etc config are also picked up?
I know even to show the figure after loading the pickle we have to create a new dummy figure and hijack its canvas manager (source):
new_manager = plt.figure().canvas.manager
new_manager.canvas.figure = fig
fig.set_canvas(new_manager.canvas)
I was wondering if similar things could be done for axes/grid/etc?