Closed remiberthoz closed 4 years ago
hmm ok. So the best thing would be probably if pylustrator.start() "just" tries to grab all existing figures. Or that you can call pylustrator.start(fig) with an existing figure. I want to keep the API as small as possible.
I added this code to pylustrator.start() to enable pylustartor for already existing figures. I hope this solves your problem!
Hey, thanks for the implementation. That was fast :) !
It may have introduced a bug though... If I run:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.text(0.5, 0.5, 'Hello World!')
fig, ax = plt.subplots()
ax.text(0.5, 0.5, 'Hey Earth!')
import pylustrator
pylustrator.start()
plt.show()
then I get a RuntimeError: OrderedDict mutated during iteration
from:
File "./pylustrator/pylustrator/QtGuiDrag.py", line 93, in initialize
for fig_number in _pylab_helpers.Gcf.figs:
I can solve it using: for fig_number in _pylab_helpers.Gcf.figs.copy()
instead ; then the same errors appears from line 111
and the same fix works. I'm not sure if this has side-effects though.
I'll test it more today and report back!
Thank you for the test and suggestion to improve. I implemented your fix.
Hello! Pylustrator is an awesome tool, thanks!
I would like to ask whether you would agree to add a function that converts an existing matplotlib
Figure
to a figure editable with the Pylustrator GUI.My use case is the following:
I know you already support
load('project1.ipynb')
for a similar use case. But if the computations for analysis are long, it would be nice to separate both aspects. When the notebook has to be executed on a headless high performance computing cluster, pylustrator cannot be used at all.Thanks again!
I tested a basic implementation of a
convertFromPyplot
function, copying what you have inloadFromFile(cache = True)
:and it appears to be working with this test script:
though I'm not sure how robust it is. If it looks good to you, I will be happy to open a pull request!