From 0618330139bf316f45b8f245ee7fff6cc863c80c Mon Sep 17 00:00:00 2001 From: Martin Killenberg <martin.killenberg@desy.de> Date: Wed, 11 Jan 2023 17:59:17 +0100 Subject: [PATCH] add pdf plotting functionality to MeasurementPlot --- Python_script/MeasurementPlot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Python_script/MeasurementPlot.py b/Python_script/MeasurementPlot.py index deddcd5..16ccd55 100644 --- a/Python_script/MeasurementPlot.py +++ b/Python_script/MeasurementPlot.py @@ -47,7 +47,7 @@ class MeasurementPlot: labels = [pc.get_label() for pc in all_path_collections] self.ax1[1].legend(all_path_collections, labels, loc='lower right') - def draw(self, data_frame, save_pdf=True): + def draw(self, data_frame, pdf_name=''): timestamps = data_frame.TIMESTAMP minimum, maximum = self.get_extended_min_max(timestamps) self.ax1[0].set_xlim(minimum, maximum) @@ -76,13 +76,17 @@ class MeasurementPlot: self.path_collection_equi0.set_offsets(np.c_[timestamps, data_frame.EQUILIBRIUM_INDICATOR]) self.path_collection_equi1.set_offsets(np.c_[timestamps, data_frame.EQUILIBRIUM_INDICATOR]) + if not pdf_name == '': + self.fig.savefig(pdf_name) + plt.show() if plt.isinteractive(): self.fig.canvas.draw() self.fig.canvas.flush_events() # add 5 % of the distance between min and max to the range - def get_extended_min_max(self, array): + @staticmethod + def get_extended_min_max(array): distance = array.max() - array.min() return array.min()-0.05*distance, array.max()+0.05*distance @@ -108,4 +112,4 @@ if __name__ == '__main__': print('I am done. ') plt.ioff() - m.draw(data_frame) + m.draw(data_frame, 'the.pdf') -- GitLab