You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pl.show() still not working (?) in interactive mode #68
I am using the latest code from main. If I run this code as a script, the plot is shown. If I set a breakpoint (I am using PyCharm) in the line with pl.render_points()..., and then run that line in the Python interactive console, then no plot is shown and I need to call plt.show() explicitly. I think the bug was once fixed, maybe it slipped in again.
changed the title [-]`pl.show()` still not working (?) in interactive mode?[/-][+]`pl.show()` still not working (?) in interactive mode[/+]on May 14, 2023
It seems like the bug resurfaced. By running the code of this comment here (please delete the Interactive() calls) scverse/napari-spatialdata#175 (comment), in a Python console, the plots are shown only if plt.show() is called explicitly.
# Manually show plot if we're not in interactive mode# https://stackoverflow.com/a/64523765ifnothasattr(sys, "ps1"):
plt.show()
doesn't cover the case in which we are in Python console.
II think that the solution proposed in #71, would solve both bugs: I suggest to add a parameter show: bool = None. If ax is not None, show is set to False, otherwise it is set to True.
Then I would replace the line if not hasattr(sys, "ps1"): with if show:. Anyway I kindly ask you to double check please.
I might be having the same problem today. Running spatial-data master (471ae71dcc84754fe5c2cd48d9fe46a153ee2dee) and spatialdata-plot also at master (227434d):
If I run a script via python myscript.py, then pl.show() will show the plot.
If I copy the script and paste it into a python REPL, the plot doesn't show;
If I run the script with pytho -i, the plot is shown but further attempts to show the plot don't work;
manually calling matplotlib.interactive(True) makes the plotting work again for the remainder of the session
Activity
[-]`pl.show()` still not working (?) in interactive mode?[/-][+]`pl.show()` still not working (?) in interactive mode[/+]LucaMarconato commentedon Nov 5, 2023
It seems like the bug resurfaced. By running the code of this comment here (please delete the
Interactive()calls) scverse/napari-spatialdata#175 (comment), in a Python console, the plots are shown only ifplt.show()is called explicitly.LucaMarconato commentedon Nov 5, 2023
It seems like that the check:
doesn't cover the case in which we are in Python console.
II think that the solution proposed in #71, would solve both bugs: I suggest to add a parameter
show: bool = None. Ifaxis notNone,showis set toFalse, otherwise it is set toTrue.Then I would replace the line
if not hasattr(sys, "ps1"):withif show:. Anyway I kindly ask you to double check please.grst commentedon Feb 15, 2024
You could also look into
plt.ion()/plt.ioff().If interactive mode is activated, figures will be shown and redrawn automatically on each update. In jupyter notebooks, this is active by default.
I lean towards reducing the number of options like
show =Falseand instead educate the users about such matplotlib options in the tutorials.Improve interactive mode detection for plt.show() auto-behavior
Tomaz-Vieira commentedon Jun 24, 2026
I might be having the same problem today. Running spatial-data master (471ae71dcc84754fe5c2cd48d9fe46a153ee2dee) and spatialdata-plot also at master (227434d):
python myscript.py, thenpl.show()will show the plot.pytho -i, the plot is shown but further attempts to show the plot don't work;manually calling
matplotlib.interactive(True)makes the plotting work again for the remainder of the sessiontimtreis commentedon Jun 24, 2026
Hey @Tomaz-Vieira, could you try #745?