From 01009cc4a70739a02e4b1933b311055eff5122ec Mon Sep 17 00:00:00 2001 From: FQT Date: Tue, 21 Nov 2017 17:22:28 +1100 Subject: [PATCH 1/2] fix: MatPlot.rescale_axis works with multiple traces, arrays other than DataArray --- qcodes/plots/qcmatplotlib.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/qcodes/plots/qcmatplotlib.py b/qcodes/plots/qcmatplotlib.py index c294aba65899..029ffa436eeb 100644 --- a/qcodes/plots/qcmatplotlib.py +++ b/qcodes/plots/qcmatplotlib.py @@ -14,6 +14,8 @@ from .base import BasePlot import qcodes.config +from qcodes import DataArray + class MatPlot(BasePlot): """ @@ -55,7 +57,7 @@ def __init__(self, *args, figsize=None, interval=1, subplots=None, num=None, subplots = max(len(args), 1) self._init_plot(subplots, figsize, num=num) - + # Add data to plot if passed in args, kwargs are passed to all subplots for k, arg in enumerate(args): if isinstance(arg, Sequence): @@ -417,11 +419,17 @@ def scale_formatter(i, pos, scale): return "{0:g}".format(i * scale) for i, subplot in enumerate(self.subplots): + traces = [trace for trace in self.traces if trace['config'].get('subplot', None) == i+1] + if not traces: + continue + else: + # TODO: include all traces when calculating maxval etc. + trace = traces[0] for axis in 'x', 'y', 'z': - if self.traces[i]['config'].get(axis): - unit = self.traces[i]['config'][axis].unit - label = self.traces[i]['config'][axis].label - maxval = abs(self.traces[i]['config'][axis].ndarray).max() + if axis in trace['config'] and isinstance(trace['config'][axis], DataArray): + unit = trace['config'][axis].unit + label = trace['config'][axis].label + maxval = np.nanmax(abs(trace['config'][axis].ndarray)) units_to_scale = self.standardunits # allow values up to a <1000. i.e. nV is used up to 1000 nV From 94cc08a881c89fb1704f3fa2e75de43bf17f7e6c Mon Sep 17 00:00:00 2001 From: nulinspiratie Date: Sat, 2 Dec 2017 18:56:07 +1100 Subject: [PATCH 2/2] fix: absolute import --- qcodes/plots/qcmatplotlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/plots/qcmatplotlib.py b/qcodes/plots/qcmatplotlib.py index 029ffa436eeb..27fcfcf2b2ba 100644 --- a/qcodes/plots/qcmatplotlib.py +++ b/qcodes/plots/qcmatplotlib.py @@ -14,7 +14,7 @@ from .base import BasePlot import qcodes.config -from qcodes import DataArray +from qcodes.data.data_array import DataArray class MatPlot(BasePlot):