From b7ff35485e5aa15faeb2eef754b91134ca93e765 Mon Sep 17 00:00:00 2001 From: jan Date: Wed, 25 May 2016 00:39:37 -0700 Subject: [PATCH] Add an option to defer showing plots when calling visualize_* --- gridlock/grid.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gridlock/grid.py b/gridlock/grid.py index bf09a7a..933fb45 100644 --- a/gridlock/grid.py +++ b/gridlock/grid.py @@ -681,7 +681,8 @@ class Grid(object): surface_normal: Direction or int, center: float, which_shifts: int=0, - sample_period: int=1): + sample_period: int=1, + finalize: bool=True): """ Visualize a slice of a grid. Interpolates if given a position between two planes. @@ -748,13 +749,15 @@ class Grid(object): pyplot.gca().set_aspect('equal', adjustable='box') pyplot.xlabel(x_label) pyplot.ylabel(y_label) - pyplot.show() + if finalize: + pyplot.show() def visualize_isosurface(self, level: float=None, which_shifts: int=0, sample_period: int=1, - show_edges: bool=True): + show_edges: bool=True, + finalize: bool=True): """ Draw an isosurface plot of the device. @@ -801,4 +804,5 @@ class Grid(object): for xb, yb, zb in zip(xbs, ybs, zbs): ax.plot([xb], [yb], [zb], 'w') - pyplot.show() + if finalize: + pyplot.show()