From 681f295e6331eaf304de9decc95de8c9d7d77af5 Mon Sep 17 00:00:00 2001 From: Martin Killenberg <martin.killenberg@desy.de> Date: Tue, 10 Jan 2023 15:08:38 +0100 Subject: [PATCH] prepare plot_measurement for re-plotting --- Python_script/prototype.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Python_script/prototype.py b/Python_script/prototype.py index cdef1f1..17ba5f6 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -276,8 +276,10 @@ class Measurements: (float(readback_hum) <= target_hum+self.max_delta_hum) # plot a single measurement (phase, magnitude, temp and hum against time) from a pandas data frame -def plot_measurement(data_frame, show_plot_window, save_pdf=True): - fig, ax1 = plt.subplots(2, figsize=(12, 10)) +def plot_measurement(data_frame, show_blocking_plot, save_pdf=True, subplot_tuple = (None, None)): + fig, ax1 = subplot_tuple + if fig is None or ax1 is None: + fig, ax1 = plt.subplots(2, figsize=(12, 10)) fig.suptitle("Graphical representation of chamber output", color="red") path_collection01 = ax1[0].scatter(data_frame.TIMESTAMP, data_frame.S21_PHASE, c='red', marker='<', label='Phase') @@ -319,12 +321,16 @@ def plot_measurement(data_frame, show_plot_window, save_pdf=True): if save_pdf: fig.savefig(output_basename + '_graph.pdf') - if show_plot_window: - plt.show() + # turn interactive on if we are not supposed to block, otherwise turn it off + if show_blocking_plot: + plt.ioff() + else: + plt.ion() + plt.show() -def plot_output(output_basename, show_plot_window, save_pdf=True): +def plot_output(output_basename, show_blocking_plot, save_pdf=True): data_frame = pd.read_csv(output_basename+'.csv') - plot_measurement(data_frame, show_plot_window, save_pdf) + plot_measurement(data_frame, show_blocking_plot, save_pdf) if __name__ == '__main__': parser = ArgumentParser() @@ -344,7 +350,7 @@ if __name__ == '__main__': help="Change Chamber mode to standby at the end") parser.add_argument("-p", "--plot", action="store_true", default=False, - help="Show plot window at the end") + help="Show blocking plot window at the end") # parser.add_argument("-q", "--quiet", # action="store_false", dest="verbose", default=True, -- GitLab