Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MatPlot.rescale_axis fixes #875

Merged
merged 3 commits into from
Dec 4, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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