4

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.

9
  • Update: I changed the code to include plt.figure(1) and plt.figure(2) before each plt.title("...") call and both get displayed separately but both immediately. This is not blocking, but it is a probably going to be acceptable for this 2 graph situation. There is another with 14 graphs so a solution to why this didn't block would still be appreciated. Commented Oct 29, 2015 at 20:39
  • plt.show should block by default. Is your example the whole code? Look for something like plt.ion().
    – MaxNoe
    Commented Oct 30, 2015 at 3:40
  • This is not all the code. The application contains multiple files and classes, ... not a ton, but quite a bit of code. Anyway, I did a search through all the code for "ion" and it is not in the code anywhere. A small extra note, the "block=True" in the plt.show() call, ... I added after I saw it in another posting somewhere ... it had no affect on the issue. Commented Oct 30, 2015 at 14:45
  • How do you run the code? Are you maybe using Ipython? Or are you having matplotlibrc with the option interactive: true? What happens if you call plt.rcdefaults() at the very beginning of your script?
    – MaxNoe
    Commented Oct 30, 2015 at 15:54
  • I am using "JetBrains PyCharm Community Edition 4.5.4" IDE and have been running from it. After reading your question, I tried running from the command line "python Model_GUI.py" with the same result. Commented Oct 30, 2015 at 17:41

1 Answer 1

0

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.

5
  • virgula24, I did see this ... "block until the figures have been closed" ... is what was expected and desired. (Also, as I said at the top of the post, was working on the previous persons' PC.) I'm thinking it may be some sort of environment setting, python package installation thing? Commented Oct 30, 2015 at 14:52
  • im not a python expert but maybe dig into the source code of matlib for that particular function or just reimage that persons pc
    – virgula24
    Commented Oct 30, 2015 at 16:02
  • I have tried to get more documentation on these matplotlib.pyplot functions. I found manual pages but the information is very terse. Commented Oct 30, 2015 at 17:47
  • best option is to reimage that computer. or have fun digging in the source code. maybe create a issue and let them help you github.com/matplotlib/matplotlib/tree/…
    – virgula24
    Commented Nov 2, 2015 at 10:34
  • @scotlandhoy It's an issue with the environment, or a bug with your ancient version of Matplotlib/Python.
    – gboffi
    Commented May 25, 2024 at 23:55

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.