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
[Bug]: Plot window not shown in Mac OS with backend set to default MacOSX #26869
Under version 3.8.0 the plot window does not appear when using MacOSX as the backend (default under Mac OS). This is not an issues with the previous 3.7.3 version or when backend is set to TkAgg.
Code for reproduction
importmatplotlibimportmatplotlib.pyplotaspltimportnumpyasnpfrommatplotlibimportcm# matplotlib.use(backend="TkAgg")plt.style.use("_mpl-gallery")
# Make dataX=np.arange(-5, 5, 0.25)
Y=np.arange(-5, 5, 0.25)
X, Y=np.meshgrid(X, Y)
R=np.sqrt(X**2+Y**2)
Z=np.sin(R)
# Plot the surfacefig, ax=plt.subplots(subplot_kw={"projection": "3d"})
ax.plot_surface(X, Y, Z, vmin=Z.min() *2, cmap=cm.Blues)
ax.set(xticklabels=[], yticklabels=[], zticklabels=[])
plt.show(block=False)
input("Hit [return] to end")
plt.close("all")
I can confirm this doesn't work anymore with show(block=False), if you do block it works as expected. This came in via #25966 where we fixed sigint handling, but apparently introduced this.
Specifically, it looks like it was the second cleanup commit removing unnecessary code: ec6717a
@anntzer I am guessing this may be related to the multiple signal tests being flaky as well... and this comment: #25966 (comment)
I don't really have the time to investigate this in depth right now, but I guess we could always revert the "remove unnecessary code" cleanup for now as a stopgap (if it turns out that it wasn't actually so unneeded?)
I think the root cause of this is that the cleanup removed the PyOS_InputHook function that was in place and ran an event loop while waiting for the standard input. I just put up PR #26970 to try and re-implement some of that logic and things work as I'd expect, but happy to know if something still doesn't work or if there is a better way to do anything over there as well.
Activity
greglucas commentedon Sep 22, 2023
I can confirm this doesn't work anymore with
show(block=False), if you do block it works as expected. This came in via #25966 where we fixed sigint handling, but apparently introduced this.Specifically, it looks like it was the second cleanup commit removing unnecessary code: ec6717a
@anntzer I am guessing this may be related to the multiple signal tests being flaky as well... and this comment: #25966 (comment)
Nothing obvious jumps out to me at first glance other than the old versions specifically calling
CFRunLoopRun()within a while true block.ec6717a#diff-f8af2176752b51c29acf55ec5cc5d912f5459e19ed40559edcd78aaf7a6f6863L160
tacaswell commentedon Sep 22, 2023
Is
inputrunning an event loop for us?anntzer commentedon Sep 22, 2023
I don't really have the time to investigate this in depth right now, but I guess we could always revert the "remove unnecessary code" cleanup for now as a stopgap (if it turns out that it wasn't actually so unneeded?)
greglucas commentedon Oct 2, 2023
I think the root cause of this is that the cleanup removed the
PyOS_InputHookfunction that was in place and ran an event loop while waiting for the standard input. I just put up PR #26970 to try and re-implement some of that logic and things work as I'd expect, but happy to know if something still doesn't work or if there is a better way to do anything over there as well.tacaswell commentedon Oct 4, 2023
🤦🏻 Sorry I missed that when reviewing #26970 .