From 56f7ccfc78ffa8c07660c84cad3edf50d7fb96f7 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Tue, 4 Apr 2017 15:58:16 +0200 Subject: [PATCH] wrappers plotting changes (#20) * Fix: always save png Also when interrupted as requested * Fix: Matplot always step color on new trace to match qtplot --- qcodes/utils/wrappers.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/qcodes/utils/wrappers.py b/qcodes/utils/wrappers.py index 40d358921f4..6a250617218 100644 --- a/qcodes/utils/wrappers.py +++ b/qcodes/utils/wrappers.py @@ -155,6 +155,9 @@ def _save_individual_plots(data, inst_meas): if getattr(i, "names", False): # deal with multidimensional parameter for k, name in enumerate(i.names): + # Step the color on all subplots no just on plots within the same axis/subplot + # this is to match the qcodes-pyqtplot behaviour. + color = 'C' + str(counter_two) counter_two += 1 plot = MatPlot() inst_meas_name = "{}_{}".format(i._instrument.name, name) @@ -163,11 +166,14 @@ def _save_individual_plots(data, inst_meas): plot.subplots[0].grid() plot.save("{}_{:03d}.pdf".format(plot.get_default_title(), counter_two)) else: + # Step the color on all subplots no just on plots within the same axis/subplot + # this is to match the qcodes-pyqtplot behaviour. + color = 'C'+str(counter_two) counter_two += 1 plot = MatPlot() - # simple_parameters + # simple_parameter inst_meas_name = "{}_{}".format(i._instrument.name, i.name) - plot.add(getattr(data, inst_meas_name)) + plot.add(getattr(data, inst_meas_name), color=color) plot.subplots[0].set_title(title) plot.subplots[0].grid() plot.save("{}_{:03d}.pdf".format(plot.get_default_title(), counter_two)) @@ -208,9 +214,10 @@ def do1d(inst_set, start, stop, num_points, delay, *inst_meas): plottables = _select_plottables(inst_meas) plot = _plot_setup(data, plottables) try: - _ = loop.with_bg_task(plot.update, plot.save).run() + _ = loop.with_bg_task(plot.update).run() except KeyboardInterrupt: print("Measurement Interrupted") + plot.save() _save_individual_plots(data, plottables) if CURRENT_EXPERIMENT.get('device_image'): log.debug('Saving device image') @@ -243,9 +250,10 @@ def do1dDiagonal(inst_set, inst2_set, start, stop, num_points, delay, start2, sl plottables = _select_plottables(inst_meas) plot = _plot_setup(data, plottables) try: - _ = loop.with_bg_task(plot.update, plot.save).run() + _ = loop.with_bg_task(plot.update).run() except KeyboardInterrupt: print("Measurement Interrupted") + plot.save() _save_individual_plots(data, plottables) if CURRENT_EXPERIMENT.get('device_image'): save_device_image() @@ -282,9 +290,10 @@ def do2d(inst_set, start, stop, num_points, delay, inst_set2, start2, stop2, num plottables = _select_plottables(inst_meas) plot = _plot_setup(data, plottables) try: - _ = loop.with_bg_task(plot.update, plot.save).run() + _ = loop.with_bg_task(plot.update).run() except KeyboardInterrupt: print("Measurement Interrupted") + plot.save() _save_individual_plots(data, plottables) if CURRENT_EXPERIMENT.get('device_image'): save_device_image()