rgerum / pylustrator

Visualisations of data are at the core of every publication of scientific research results. They have to be as clear as possible to facilitate the communication of research. As data can have different formats and shapes, the visualisations often have to be adapted to reflect the data as well as possible. We developed Pylustrator, an interface to directly edit python generated matplotlib graphs to finalize them for publication. Therefore, subplots can be resized and dragged around by the mouse, text and annotations can be added. The changes can be saved to the initial plot file as python code.
GNU General Public License v3.0
707 stars 37 forks source link

Feature request: loading and editing pickle-dumped figures #39

Closed arashgmn closed 2 years ago

arashgmn commented 2 years ago

First of all, awesome work! Thank you.

Matplotlib folks suggest saving figure objects as a pickle for later modification.

import matplotlib.pyplot as plt
import pickle 

# plot a fancy figure
# ...

fig = plt.gcf()
pickle.dump(fig, open('figObj.pickle', 'wb')) # for future

I was thinking it would be truly amazing if pylustrator could pick up the editing job from those saved picked. Something like this:

import matplotlib.pyplot as plt
import pylustrator
pylustrator.start()

pylustrator.pickle_load('figObj.pickle') # interactive editing 

Looking forward to the future of pylustrator! Arash

rgerum commented 2 years ago

I am not sure if i want to recommend people using pickel files as they are not intended for long term storage as the serialisation can change between python versions. But I can have a look if it is possible to implemented such a feature for pylustrator. And yes in general it would be great to have a good format to save matplotlib figures.

rgerum commented 2 years ago

With this commit you should be able to start pylustrator after figure generation. Which means you should be able to load your figure from pickle first and then start pylustrator. You can install the repository version with

pip install git+https://github.com/rgerum/pylustrator