Skip to content

Commit 4880bef

Browse files
nulinspiratiejenshnielsen
authored andcommitted
fix: MatPlot.rescale_axis fixes (#875)
* fix: MatPlot.rescale_axis works with multiple traces, arrays other than DataArray * fix: absolute import
1 parent a77ea1e commit 4880bef

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

qcodes/plots/qcmatplotlib.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
from .base import BasePlot
1616
import qcodes.config
17+
from qcodes.data.data_array import DataArray
18+
1719

1820
class MatPlot(BasePlot):
1921
"""
@@ -55,7 +57,7 @@ def __init__(self, *args, figsize=None, interval=1, subplots=None, num=None,
5557
subplots = max(len(args), 1)
5658

5759
self._init_plot(subplots, figsize, num=num)
58-
60+
5961
# Add data to plot if passed in args, kwargs are passed to all subplots
6062
for k, arg in enumerate(args):
6163
if isinstance(arg, Sequence):
@@ -417,11 +419,17 @@ def scale_formatter(i, pos, scale):
417419
return "{0:g}".format(i * scale)
418420

419421
for i, subplot in enumerate(self.subplots):
422+
traces = [trace for trace in self.traces if trace['config'].get('subplot', None) == i+1]
423+
if not traces:
424+
continue
425+
else:
426+
# TODO: include all traces when calculating maxval etc.
427+
trace = traces[0]
420428
for axis in 'x', 'y', 'z':
421-
if self.traces[i]['config'].get(axis):
422-
unit = self.traces[i]['config'][axis].unit
423-
label = self.traces[i]['config'][axis].label
424-
maxval = abs(self.traces[i]['config'][axis].ndarray).max()
429+
if axis in trace['config'] and isinstance(trace['config'][axis], DataArray):
430+
unit = trace['config'][axis].unit
431+
label = trace['config'][axis].label
432+
maxval = np.nanmax(abs(trace['config'][axis].ndarray))
425433
units_to_scale = self.standardunits
426434

427435
# allow values up to a <1000. i.e. nV is used up to 1000 nV

0 commit comments

Comments
 (0)