zxcalc / pyzx

Python library for quantum circuit rewriting and optimisation using the ZX-calculus
Apache License 2.0
385 stars 116 forks source link

Why does the draw_matplotlib function close the figure before returning it? #276

Open mehatamm opened 2 days ago

mehatamm commented 2 days ago

It seems that the draw_matplotlib function in pyzx/drawing.py used to plt.show(), but was changed to plt.close() and then returns the figure. To then visualize the figure, it is necessary to create a dummy figure and then move the returned figure to its manager, but this breaks interactivity on my backend (MacOSX). Is there any particular reason why the figure is closed before returning?

jvdwetering commented 19 hours ago

I am not sure why this there to be honest. My guess is that it was causing weird behaviour on certain platforms. I guess there could be an optional parameter to disable this behaviour.