For a script this isn't a problem because any errors will stop execution immediately, but doing this avoids issues with the state of the PHA persisting between different cells of jupyter notebook (thus producing weird errors when a cell failed to plot a 1D spectrum, and the next cell tries to stage a 2D spectrum).
For a script this isn't a problem because any errors will stop execution immediately, but doing this avoids issues with the state of the PHA persisting between different cells of jupyter notebook (thus producing weird errors when a cell failed to plot a 1D spectrum, and the next cell tries to stage a 2D spectrum).
Just use try/finally code inside mkplot().