patchworklib
patchworklib copied to clipboard
How to load a matplotlib / seaborn plot that was already created
Hello,
Thanks for this cool library - super helpful!
I'm creating plots in multiple notebooks / python scripts and save them to pickle. Than from a central notebook I combine them in the final figure using patchworklib. to do this i am trying it in two different ways:
- Exporting bricks object to pickle and loading the pickle object somewhere else
import seaborn as sns
import patchworklib as pw
ax = pw.Brick(figsize=(3, 2))
sns.lineplot(melted_dilution, x="VAF %", y="Metric Value", hue="Metric", ax=ax)
dump_to_pickle(ax)
and than in another notebook
ax = load_pickle(path_to_file)
ax.savefid()
- Exporting the matplotlib figure object, loading it in the other notebook and putting the
axin theBricksobject
import seaborn as sns
ax=sns.lineplot(melted_dilution, x="VAF %", y="Metric Value", hue="Metric")
dump_to_pickle(ax.get_figure())
and than in another notebook
fig = load_pickle(path_to_file)
brick =pw.Brick(ax=fig.axes[0])
the problem i have is that in both of these ways:
- the bricks object contains the figure and the axes (i.e
brick.figurereturns the plot) - but if i do
brick.savefig("test.png")or justbrickin the notebook there is only a blank canvas.
any advice on how to do this?
Thanks a lot!