Skip to content

Commit

Permalink
fix: MatPlot.rescale_axis fixes (#875)
Browse files Browse the repository at this point in the history
* fix: MatPlot.rescale_axis works with multiple traces, arrays other than DataArray

* fix: absolute import
  • Loading branch information
nulinspiratie authored and jenshnielsen committed Dec 4, 2017
1 parent a77ea1e commit 4880bef
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions qcodes/plots/qcmatplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

from .base import BasePlot
import qcodes.config
from qcodes.data.data_array import DataArray


class MatPlot(BasePlot):
"""
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4880bef

Please sign in to comment.