Search code examples
pythonmatplotlibparallel-processinggil

Python: Plot some data (matplotlib) without GIL


my problem is the GIL of course. While I'm analysing data it would be nice to present some plots in between (so it's not too boring waiting for results)

But the GIL prevents this (and this is bringing me to the point of asking myself if Python was such a good idea in the first place).

I can only display the plot, wait till the user closes it and commence calculations after that. A waste of time obviously.

I already tried the subprocess and multiprocessing modules but can't seem to get them to work.

Any thoughts on this one? Thanks

Edit: Ok so it's not the GIL but show().


Solution

  • This is not a problem from matplotlib or the GIL.

    In matplotlib You can open as many figures as you want and have them in the screen while your application continues doing other things.

    You must use matplotlib in interactive mode. This probably is your problem.

    from matplotlib import interactive
    interactive(True)
    

    this should be at the top of your imports