Commit f39153db authored by Gordian Edenhofer's avatar Gordian Edenhofer
Browse files

Allow for non-blocking plots

Pass the `block` keyword on to `matplotlib.pyplot` as to allow for
non-blocking interactive plot windows to be created. This is useful for
creating several plots in fast succession without the python script
blocking the current process.
parent 2e63dd00
Pipeline #62615 passed with stages
in 7 minutes and 33 seconds
......@@ -171,14 +171,15 @@ def _find_closest(A, target):
return idx
def _makeplot(name):
def _makeplot(name, block=True):
import matplotlib.pyplot as plt
if dobj.rank != 0:
if name is None:
if block:
extension = os.path.splitext(name)[1]
if extension in (".pdf", ".png", ".svg"):
......@@ -496,6 +497,9 @@ class Plot(object):
If left empty, the plot will be shown on the screen,
otherwise it will be written to a file with the given name.
Supported extensions: .png and .pdf. Default: None.
block: bool
Override the blocking behavior of the non-interactive plotting
mode. The plot will not be closed in this case but is left open!
import matplotlib.pyplot as plt
nplot = len(self._plots)
......@@ -522,4 +526,4 @@ class Plot(object):
ax = fig.add_subplot(ny, nx, i+1)
_plot(self._plots[i], ax, **self._kwargs[i])
_makeplot(kwargs.pop("name", None))
_makeplot(kwargs.pop("name", None), block=kwargs.pop("block", True))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment