diff --git a/Python_script/prototype.py b/Python_script/prototype.py index cdef1f1d2eeeb7264bc81fadbe334c8dff470b23..17ba5f691b763f562de122455dc16ba44a6beceb 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,