From 4d389464c6cdfb2c72b533a4d1fb66b6750191a0 Mon Sep 17 00:00:00 2001 From: Documentation Bot Date: Thu, 2 Mar 2017 16:59:33 +0000 Subject: [PATCH] Generated gh-pages for commit e95d623 Author: Giulio Ungaretti feature: Use unit in label (#495) --- _modules/qcodes/plots/pyqtgraph.html | 54 +++++++++++++----- _modules/qcodes/plots/qcmatplotlib.html | 56 ++++++++++++++++--- .../qcodes.instrument_drivers.QDev.html | 2 +- .../qcodes.instrument_drivers.ithaco.html | 2 +- ...codes.instrument_drivers.signal_hound.html | 2 +- ....instrument_drivers.stanford_research.html | 2 +- .../qcodes.instrument_drivers.tektronix.html | 4 +- 7 files changed, 95 insertions(+), 27 deletions(-) diff --git a/_modules/qcodes/plots/pyqtgraph.html b/_modules/qcodes/plots/pyqtgraph.html index d06af84a026..6620b49695d 100644 --- a/_modules/qcodes/plots/pyqtgraph.html +++ b/_modules/qcodes/plots/pyqtgraph.html @@ -310,6 +310,8 @@

Source code for qcodes.plots.pyqtgraph

         return [self._clean_array(arg) for arg in [x, y] if arg is not None]
 
     def _draw_image(self, subplot_object, z, x=None, y=None, cmap='hot',
+                    zlabel=None,
+                    zunit=None,
                     **kwargs):
         img = self.rpg.ImageItem()
         subplot_object.addItem(img)
@@ -317,10 +319,14 @@ 

Source code for qcodes.plots.pyqtgraph

         hist = self.rpg.HistogramLUTItem()
         hist.setImageItem(img)
         hist.axis.setPen(self.theme[0])
-        if 'zlabel' in kwargs:  # used to specify a custom zlabel
-            hist.axis.setLabel(kwargs['zlabel'])
-        else:  # otherwise extracts the label from the dataarray
-            hist.axis.setLabel(self.get_label(z))
+
+        if zunit is None:
+            _, zunit = self.get_label(z)
+        if zlabel is None:
+            zlabel, _ = self.get_label(z)
+
+        hist.axis.setLabel(zlabel, zunit)
+
         # TODO - ensure this goes next to the correct subplot?
         self.win.addItem(hist)
 
@@ -501,22 +507,42 @@ 

Source code for qcodes.plots.pyqtgraph

         """
         Updates x and y labels, by default tries to extract label from
         the DataArray objects located in the trace config. Custom labels
-        can be specified the **kwargs "xlabel" and "ylabel"
+        can be specified the **kwargs "xlabel" and "ylabel". Custom units
+        can be specified using the kwargs xunit, ylabel
         """
         for axletter, side in (('x', 'bottom'), ('y', 'left')):
             ax = subplot_object.getAxis(side)
-            # pyqtgraph doesn't seem able to get labels, only set
-            # so we'll store it in the axis object and hope the user
-            # doesn't set it separately before adding all traces
+            # danger: 🍝
+            # find if any kwarg from plot.add in the base class
+            # matches xlabel or ylabel, signaling a custom label
             if axletter+'label' in config and not ax._qcodes_label:
                 label = config[axletter+'label']
-                ax._qcodes_label = label
-                ax.setLabel(label)
+            else:
+                label = None
+
+            # find if any kwarg from plot.add in the base class
+            # matches xunit or yunit, signaling a custom unit
+            if axletter+'unit' in config and not ax._qcodes_label:
+                unit = config[axletter+'unit']
+            else:
+                unit = None
+
+            #  find ( more hope to) unit and label from
+            # the data array inside the config
             if axletter in config and not ax._qcodes_label:
-                label = self.get_label(config[axletter])
-                if label:
-                    ax._qcodes_label = label
-                    ax.setLabel(label)
+                # now if we did not have any kwark gor label or unit
+                # fallback to the data_array
+                if unit is  None:
+                    _, unit = self.get_label(config[axletter])
+                if label is None:
+                    label, _ = self.get_label(config[axletter])
+
+            # pyqtgraph doesn't seem able to get labels, only set
+            # so we'll store it in the axis object and hope the user
+            # doesn't set it separately before adding all traces
+            ax._qcodes_label = label
+            ax._qcodes_unit = unit
+            ax.setLabel(label, unit)
 
     def update_plot(self):
         for trace in self.traces:
diff --git a/_modules/qcodes/plots/qcmatplotlib.html b/_modules/qcodes/plots/qcmatplotlib.html
index 3ab53a1eadc..91af1c98525 100644
--- a/_modules/qcodes/plots/qcmatplotlib.html
+++ b/_modules/qcodes/plots/qcmatplotlib.html
@@ -268,10 +268,32 @@ 

Source code for qcodes.plots.qcmatplotlib

         return self.subplots[config.get('subplot', 1) - 1]
 
     def _update_labels(self, ax, config):
-        if 'x' in config and not ax.get_xlabel():
-            ax.set_xlabel(self.get_label(config['x']))
-        if 'y' in config and not ax.get_ylabel():
-            ax.set_ylabel(self.get_label(config['y']))
+        for axletter in ("x", "y"):
+            if axletter+'label' in config:
+                label = config[axletter+'label']
+            else:
+                label = None
+
+            # find if any kwarg from plot.add in the base class
+            # matches xunit or yunit, signaling a custom unit
+            if axletter+'unit' in config:
+                unit = config[axletter+'unit']
+            else:
+                unit = None
+
+            #  find ( more hope to) unit and label from
+            # the data array inside the config
+            getter = getattr(ax, "get_{}label".format(axletter))
+            if axletter in config and not getter():
+                # now if we did not have any kwark gor label or unit
+                # fallback to the data_array
+                if unit is  None:
+                    _, unit = self.get_label(config[axletter])
+                if label is None:
+                    label, _ = self.get_label(config[axletter])
+
+            axsetter = getattr(ax, "set_{}label".format(axletter))
+            axsetter("{} ({})".format(label, unit))
 
     def update_plot(self):
         """
@@ -321,7 +343,14 @@ 

Source code for qcodes.plots.qcmatplotlib

 
         self.fig.canvas.draw()
 
-    def _draw_plot(self, ax, y, x=None, fmt=None, subplot=1, **kwargs):
+    def _draw_plot(self, ax, y, x=None, fmt=None, subplot=1,
+                   xlabel=None,
+                   ylabel=None,
+                   zlabel=None,
+                   xunit=None,
+                   yunit=None,
+                    zunit=None,
+                   **kwargs):
         # NOTE(alexj)stripping out subplot because which subplot we're in is already
         # described by ax, and it's not a kwarg to matplotlib's ax.plot. But I
         # didn't want to strip it out of kwargs earlier because it should stay
@@ -330,7 +359,14 @@ 

Source code for qcodes.plots.qcmatplotlib

         line, = ax.plot(*args, **kwargs)
         return line
 
-    def _draw_pcolormesh(self, ax, z, x=None, y=None, subplot=1, **kwargs):
+    def _draw_pcolormesh(self, ax, z, x=None, y=None, subplot=1,
+                         xlabel=None,
+                         ylabel=None,
+                         zlabel=None,
+                         xunit=None,
+                         yunit=None,
+                         zunit=None,
+                         **kwargs):
         # NOTE(alexj)stripping out subplot because which subplot we're in is already
         # described by ax, and it's not a kwarg to matplotlib's ax.plot. But I
         # didn't want to strip it out of kwargs earlier because it should stay
@@ -360,7 +396,13 @@ 

Source code for qcodes.plots.qcmatplotlib

             # I guess we could create the colorbar no matter what,
             # and just give it a dummy mappable to start, so we could
             # put this where it belongs.
-            ax.qcodes_colorbar.set_label(self.get_label(z))
+            if zunit is None:
+                _, zunit = self.get_label(z)
+            if zlabel is None:
+                zlabel, _ = self.get_label(z)
+
+            label = "{} ({})".format(zlabel, zunit)
+            ax.qcodes_colorbar.set_label(label)
 
         return pc
 
diff --git a/api/generated/qcodes.instrument_drivers.QDev.html b/api/generated/qcodes.instrument_drivers.QDev.html
index 53108bfe6d4..cd13927d6ff 100644
--- a/api/generated/qcodes.instrument_drivers.QDev.html
+++ b/api/generated/qcodes.instrument_drivers.QDev.html
@@ -265,7 +265,7 @@ 

Submodules
-voltage_range_status = {'X 1': 10, 'X 0.1': 1}
+voltage_range_status = {'X 0.1': 1, 'X 1': 10}
diff --git a/api/generated/qcodes.instrument_drivers.ithaco.html b/api/generated/qcodes.instrument_drivers.ithaco.html index 0cade37e8ca..87f72c6cb0f 100644 --- a/api/generated/qcodes.instrument_drivers.ithaco.html +++ b/api/generated/qcodes.instrument_drivers.ithaco.html @@ -212,7 +212,7 @@

SubmodulesParameters:

diff --git a/api/generated/qcodes.instrument_drivers.stanford_research.html b/api/generated/qcodes.instrument_drivers.stanford_research.html index d62d3e7f1aa..20dc719821e 100644 --- a/api/generated/qcodes.instrument_drivers.stanford_research.html +++ b/api/generated/qcodes.instrument_drivers.stanford_research.html @@ -249,7 +249,7 @@

SubmodulesParameters:

-AWG_FILE_FORMAT_HEAD = {'TRIGGER_INPUT_THRESHOLD': 'd', 'HOLD_REPETITION_RATE': 'h', 'ZEROING': 'h', 'WAIT_VALUE': 'h', 'INTERLEAVE': 'h', 'REPETITION_RATE': 'd', 'RUN_STATE': 'h', 'CLOCK_SOURCE': 'h', 'EVENT_INPUT_THRESHOLD': 'd', 'TRIGGER_INPUT_IMPEDANCE': 'h', 'TRIGGER_INPUT_SLOPE': 'h', 'REFERENCE_MULTIPLIER_RATE': 'h', 'EXTERNAL_REFERENCE_TYPE': 'h', 'INTERLEAVE_ADJ_PHASE': 'd', 'INTERNAL_TRIGGER_RATE': 'd', 'SAMPLING_RATE': 'd', 'REFERENCE_CLOCK_FREQUENCY_SELECTION': 'h', 'JUMP_TIMING': 'h', 'COUPLING': 'h', 'TRIGGER_INPUT_POLARITY': 'h', 'DIVIDER_RATE': 'h', 'RUN_MODE': 'h', 'INTERLEAVE_ADJ_AMPLITUDE': 'd', 'REFERENCE_SOURCE': 'h', 'TRIGGER_SOURCE': 'h', 'EVENT_INPUT_IMPEDANCE': 'h', 'EVENT_INPUT_POLARITY': 'h'}
+AWG_FILE_FORMAT_HEAD = {'JUMP_TIMING': 'h', 'TRIGGER_SOURCE': 'h', 'DIVIDER_RATE': 'h', 'RUN_MODE': 'h', 'EXTERNAL_REFERENCE_TYPE': 'h', 'INTERNAL_TRIGGER_RATE': 'd', 'WAIT_VALUE': 'h', 'TRIGGER_INPUT_IMPEDANCE': 'h', 'EVENT_INPUT_IMPEDANCE': 'h', 'INTERLEAVE_ADJ_PHASE': 'd', 'INTERLEAVE': 'h', 'REFERENCE_MULTIPLIER_RATE': 'h', 'TRIGGER_INPUT_SLOPE': 'h', 'CLOCK_SOURCE': 'h', 'REFERENCE_SOURCE': 'h', 'EVENT_INPUT_THRESHOLD': 'd', 'HOLD_REPETITION_RATE': 'h', 'SAMPLING_RATE': 'd', 'REFERENCE_CLOCK_FREQUENCY_SELECTION': 'h', 'TRIGGER_INPUT_THRESHOLD': 'd', 'INTERLEAVE_ADJ_AMPLITUDE': 'd', 'REPETITION_RATE': 'd', 'RUN_STATE': 'h', 'EVENT_INPUT_POLARITY': 'h', 'ZEROING': 'h', 'TRIGGER_INPUT_POLARITY': 'h', 'COUPLING': 'h'}