Skip to content

How to load a matplotlib / seaborn plot that was already created #60

Description

@ThomVett

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 ax in the Bricks object
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.figure returns the plot)
  • but if i do brick.savefig("test.png") or just brick in the notebook there is only a blank canvas.

any advice on how to do this?

Thanks a lot!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions