Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python, matplotlib pyplot show() not blocking

I'm having trouble with the show() function not blocking. I've taken over a python application from someone that left and I seem to remembering this worked on his (IT reclaimed) PC. Here's the code ...

import matplotlib.pyplot as plt

plt.title("Molding X Error")
plt.xlabel("X")
plt.ylabel("X Error")
plt.plot( ... details that work and not the problem ... )
plt.show(block=True)
        
plt.title("Molding Y Error")
plt.xlabel("Y")
plt.ylabel("Y Error")        
plt.plot( ... details that work and not the problem ... )
plt.show(block=True)

On the other guys PC, the first show() would display appropriately. After dismissing the first, the second would display.

I run it, and it not only doesn't stop on the first show(), it combines data from both the first and second with the title and labels from the second.

I step through with the debugger, and the first does show, but stepping to the second the same result is seen.

Windows 7 Pro 64-bit. Python2.7.10, Anaconda 2.3.0 which contains (apparently) matplotlib1.4.3

Note: I did read through "(python) matplotlib pyplot show() .. blocking or not?" where it was from 2011 and was referring to matplotlib1.0.1 as a solution.

like image 969
scotlandhoy Avatar asked Nov 30 '25 05:11

scotlandhoy


1 Answers

http://matplotlib.org/api/pyplot_api.html?highlight=plot#matplotlib.pyplot.show

In non-interactive mode, display all figures and block until the figures have been closed; in interactive mode it has no effect unless figures were created prior to a change from non-interactive to interactive mode (not recommended). In that case it displays the figures but does not block. A single experimental keyword argument, block, may be set to True or False to override the blocking behavior described above.

like image 135
virgula24 Avatar answered Dec 01 '25 18:12

virgula24