Sets the label/legend of an axis.
764965
public PlotCanvas setAxisLabel(int axis, String label) {
        baseGrid.setAxisLabel(axis, label);
        repaint();
        return this;
    }
525487
def label_figure(axes, n_subplots, time_units, sig_name, sig_units, ylabel,
                 title):
    ""
    if title:
        axes[0].set_title(title)

    # Determine y label
    # Explicit labels take precedence if present. Otherwise, construct labels
    # using signal names and units
    if not ylabel:
        ylabel = []
        # Set default channel and signal names if needed
        if not sig_name:
            sig_name = ['ch_'+str(i) for i in range(n_subplots)]
        if not sig_units:
            sig_units = n_subplots * ['NU']

        ylabel = ['/'.join(pair) for pair in zip(sig_name, sig_units)]

        # If there are annotations with channels outside of signal range
        # put placeholders
        n_missing_labels = n_subplots - len(ylabel)
        if n_missing_labels:
            ylabel = ylabel + ['ch_%d/NU' % i for i in range(len(ylabel),
                                                             n_subplots)]

    for ch in range(n_subplots):
        axes[ch].set_ylabel(ylabel[ch])

    axes[-1].set_xlabel('/'.join(['time', time_units[:-1]]))
1298169
def _get_label(self, axis):
        """"""

        if axis == 'x':
            colname = self.x_col
        else:  # y
            colname = self.y_col

        if colname == self._idxname:
            label = 'Index'
        else:
            col = self.tab[colname]
            if col.unit:
                label = '{0} ({1})'.format(col.name, col.unit)
            else:
                label = col.name

        return label
300793
def _add_labels(ax: Axes, h: Union[Histogram1D, Histogram2D], kwargs: dict):
    
    title = kwargs.pop("title", h.title)
    xlabel = kwargs.pop("xlabel", h.axis_names[0])
    ylabel = kwargs.pop("ylabel", h.axis_names[1] if len(h.axis_names) == 2 else None)

    if title:
        ax.set_title(title)
    if xlabel:
        ax.set_xlabel(xlabel)
    if ylabel:
        ax.set_ylabel(ylabel)
    ax.get_figure().tight_layout()
273994
def _y_axis(self):
        """"""
        if not self._y_labels or not self.show_y_labels:
            return

        axis = self.svg.node(
            self.nodes['plot'],
            class_="axis y%s" % (' always_show' if self.show_y_guides else '')
        )

        if (0 not in [label[1] for label in self._y_labels]
                and self.show_y_guides):
            self.svg.node(
                axis,
                'path',
                d='M%f %f h%f' % (
                    0, 0 if self.inverse_y_axis else self.view.height,
                    self.view.width
                ),
                class_='line'
            )

        for label, position in self._y_labels:
            if self.horizontal:
                major = label in self._y_labels_major
            else:
                major = position in self._y_labels_major

            if not (self.show_minor_y_labels or major):
                continue
            guides = self.svg.node(
                axis,
                class_='%sguides' %
                ('logarithmic ' if self.logarithmic else '')
            )
            x = -5
            y = self.view.y(position)
            if not y:
                continue
            if self.show_y_guides:
                self.svg.node(
                    guides,
                    'path',
                    d='M%f %f h%f' % (0, y, self.view.width),
                    class_='%s%s%sline' % (
                        'axis ' if label == "0" else '', 'major '
                        if major else '', 'guide ' if position != 0 else ''
                    )
                )
            text = self.svg.node(
                guides,
                'text',
                x=x,
                y=y + .35 * self.style.label_font_size,
                class_='major' if major else ''
            )

            text.text = label

            if self.y_label_rotation:
                text.attrib['transform'] = "rotate(%d %f %f)" % (
                    self.y_label_rotation, x, y
                )
                if 90 < self.y_label_rotation < 270:
                    text.attrib['class'] = ' '.join((
                        text.attrib['class']
                        and text.attrib['class'].split(' ') or []
                    ) + ['backwards'])
            self.svg.node(
                guides,
                'title',
            ).text = self._y_format(position)

        if self._y_2nd_labels:
            secondary_ax = self.svg.node(self.nodes['plot'], class_="axis y2")
            for label, position in self._y_2nd_labels:
                major = position in self._y_labels_major
                if not (self.show_minor_y_labels or major):
                    continue
                # it is needed, to have the same structure as primary axis
                guides = self.svg.node(secondary_ax, class_='guides')
                x = self.view.width + 5
                y = self.view.y(position)
                text = self.svg.node(
                    guides,
                    'text',
                    x=x,
                    y=y + .35 * self.style.label_font_size,
                    class_='major' if major else ''
                )
                text.text = label
                if self.y_label_rotation:
                    text.attrib['transform'] = "rotate(%d %f %f)" % (
                        self.y_label_rotation, x, y
                    )
                    if 90 < self.y_label_rotation < 270:
                        text.attrib['class'] = ' '.join((
                            text.attrib['class']
                            and text.attrib['class'].split(' ') or []
                        ) + ['backwards'])
1233258
def _setAxesNames(self, axisNames):
        
        for col, _ in enumerate(self._fullAxisNames, self.COL_FIRST_COMBO):
            self._setHeaderLabel(col, '')

        self._axisNames = tuple(axisNames)
        self._fullAxisNames = tuple([axName + self.AXIS_POST_FIX for axName in axisNames])

        for col, label in enumerate(self._fullAxisNames, self.COL_FIRST_COMBO):
            self._setHeaderLabel(col, label)
703981
def _adjust_legend(self, overlay, axis):
        
        legend_data = []
        dimensions = overlay.kdims
        title = ', '.join([d.name for d in dimensions])
        for key, subplot in self.subplots.items():
            element = overlay.data.get(key, False)
            if not subplot.show_legend or not element: continue
            title = ', '.join([d.name for d in dimensions])
            handle = subplot.traverse(lambda p: p.handles['artist'],
                                      [lambda p: 'artist' in p.handles])
            if isinstance(overlay, NdOverlay):
                key = (dim.pprint_value(k) for k, dim in zip(key, dimensions))
                label = ','.join([str(k) + dim.unit if dim.unit else str(k) for dim, k in
                                  zip(dimensions, key)])
                if handle:
                    legend_data.append((handle, label))
            else:
                if isinstance(subplot, OverlayPlot):
                    legend_data += subplot.handles.get('legend_data', {}).items()
                elif element.label and handle:
                    legend_data.append((handle, element.label))
        all_handles, all_labels = list(zip(*legend_data)) if legend_data else ([], [])
        data = OrderedDict()
        used_labels = []
        for handle, label in zip(all_handles, all_labels):
            # Ensure that artists with multiple handles are supported
            if isinstance(handle, list): handle = tuple(handle)
            if handle and (handle not in data) and label and label not in used_labels:
                data[handle] = label
                used_labels.append(label)
        if (not len(set(data.values())) > 0) or not self.show_legend:
            legend = axis.get_legend()
            if legend:
                legend.set_visible(False)
        else:
            leg_spec = self.legend_specs[self.legend_position]
            if self.legend_cols: leg_spec['ncol'] = self.legend_cols
            leg = axis.legend(list(data.keys()), list(data.values()),
                              title=title, scatterpoints=1,
                              **dict(leg_spec, **self._fontsize('legend')))
            title_fontsize = self._fontsize('legend_title')
            if title_fontsize:
                leg.get_title().set_fontsize(title_fontsize['fontsize'])
            frame = leg.get_frame()
            frame.set_facecolor('1.0')
            frame.set_edgecolor('0.0')
            frame.set_linewidth('1.0')
            leg.set_zorder(10e6)
            self.handles['legend'] = leg
            self.handles['bbox_extra_artists'].append(leg)
        self.handles['legend_data'] = data
846703
def _set_all_axis_color(self, axis, color):
        """"""
        for prop in ['ticks', 'axis', 'major_ticks', 'minor_ticks', 'title',
                     'labels']:
            prop_set = getattr(axis.properties, prop)
            if color and prop in ['title', 'labels']:
                prop_set.fill = ValueRef(value=color)
            elif color and prop in ['axis', 'major_ticks', 'minor_ticks',
                                    'ticks']:
                prop_set.stroke = ValueRef(value=color)
125841
def getLabel(self, key):
        
        axisItem = self.getPlotItem().axes[key]['item']
        return axisItem.label.toPlainText()
340334
public void setLabel(java.lang.String label) {
        getStateHelper().put(PropertyKeys.label, label);
    }
128877
def do_label(self):
        
        outputdict = self.outputdict
        xlabel_options = self.kwargs.get("xlabel_options", {})
        self.subplot.set_xlabel(
            self.kwargs.get("xlabel", "").format(**outputdict),
            **xlabel_options)
        ylabel_options = self.kwargs.get("ylabel_options", {})
        self.subplot.set_ylabel(
            self.kwargs.get("ylabel", "").format(**outputdict),
            **ylabel_options)
        suptitle = self.kwargs.get("suptitle", None)
        if suptitle is not None:
            suptitle_options = self.kwargs.get("suptitle_options", {})
            self.figure.suptitle(
                suptitle.format(**outputdict),
                fontsize=int(self.kwargs.get("suptitle_fontsize", 15)),
                **suptitle_options)
        title = self.kwargs.get("title", None)
        if title is not None:
            title_options = self.kwargs.get("title_options", {})
            self.subplot.set_title(
                title.format(**outputdict),
                fontsize=int(self.kwargs.get("title_fontsize", 12)),
                **title_options)
        xlim = self.kwargs.get("xlim", None)
        ylim = self.kwargs.get("ylim", None)
        if xlim is not None:
            self.subplot.set_xlim(xlim)
        if ylim is not None:
            self.subplot.set_ylim(ylim)
        # axis format
        self.subplot.ticklabel_format(
            style="sci", useOffset=False,
            scilimits=self.kwargs.get("scilimits", (-4, 4))
        )
        return self
184448
def _post_plot_logic_common(self, ax, data):
        """"""

        def get_label(i):
            try:
                return pprint_thing(data.index[i])
            except Exception:
                return ''

        if self.orientation == 'vertical' or self.orientation is None:
            if self._need_to_set_index:
                xticklabels = [get_label(x) for x in ax.get_xticks()]
                ax.set_xticklabels(xticklabels)
            self._apply_axis_properties(ax.xaxis, rot=self.rot,
                                        fontsize=self.fontsize)
            self._apply_axis_properties(ax.yaxis, fontsize=self.fontsize)

            if hasattr(ax, 'right_ax'):
                self._apply_axis_properties(ax.right_ax.yaxis,
                                            fontsize=self.fontsize)

        elif self.orientation == 'horizontal':
            if self._need_to_set_index:
                yticklabels = [get_label(y) for y in ax.get_yticks()]
                ax.set_yticklabels(yticklabels)
            self._apply_axis_properties(ax.yaxis, rot=self.rot,
                                        fontsize=self.fontsize)
            self._apply_axis_properties(ax.xaxis, fontsize=self.fontsize)

            if hasattr(ax, 'right_ax'):
                self._apply_axis_properties(ax.right_ax.yaxis,
                                            fontsize=self.fontsize)
        else:  # pragma no cover
            raise ValueError
1212870
def format_axis(ax, label_padding=2, tick_padding=0, yticks_position='left'):
    """"""
    ax.xaxis.set_ticks_position('bottom')
    ax.yaxis.set_ticks_position(yticks_position)
    ax.yaxis.set_tick_params(which='both', direction='out', labelsize=fontsize,
                             pad=tick_padding, length=2, width=0.5)
    ax.xaxis.set_tick_params(which='both', direction='out', labelsize=fontsize,
                             pad=tick_padding, length=2, width=0.5)
    ax.xaxis.labelpad = label_padding
    ax.yaxis.labelpad = label_padding
    ax.xaxis.label.set_size(fontsize)
    ax.yaxis.label.set_size(fontsize)
1293
def plot_rhat(self, ax, xt_labelsize, titlesize, markersize):
        """"""
        for plotter in self.plotters.values():
            for y, r_hat, color in plotter.r_hat():
                if r_hat is not None:
                    ax.plot(r_hat, y, "o", color=color, markersize=markersize, markeredgecolor="k")
        ax.set_xlim(left=0.9, right=2.1)
        ax.set_xticks([1, 2])
        ax.tick_params(labelsize=xt_labelsize)
        ax.set_title("r_hat", fontsize=titlesize, wrap=True)
        return ax
785690
def setup_plot(self):
        
        if self.tick_label_fontsize is not None:
            self.x_tick_label_fontsize = self.tick_label_fontsize
            self.y_tick_label_fontsize = self.tick_label_fontsize

        # setup xticks and yticks and limits
        # if logspaced, the log values are used.
        xticks = np.arange(float(self.xlims[0]),
                           float(self.xlims[1])
                           + float(self.dx),
                           float(self.dx))

        yticks = np.arange(float(self.ylims[0]),
                           float(self.ylims[1])
                           + float(self.dy),
                           float(self.dy))

        xlim = [xticks.min(), xticks.max()]
        ylim = [yticks.min(), yticks.max()]

        if self.reverse_x_axis:
                xticks = xticks[::-1]
                xlim = [xticks.max(), xticks.min()]

        if self.reverse_y_axis:
                    yticks = yticks[::-1]
                    ylim = [yticks.max(), yticks.min()]

        self.axis.set_xlim(xlim)
        self.axis.set_ylim(ylim)

        # adjust ticks for spacing. If 'wide' then show all labels, if 'tight' remove end labels.
        if self.spacing == 'wide':
            x_inds = np.arange(len(xticks))
            y_inds = np.arange(len(yticks))
        else:
            # remove end labels
            x_inds = np.arange(1, len(xticks)-1)
            y_inds = np.arange(1, len(yticks)-1)

        self.axis.set_xticks(xticks[x_inds])
        self.axis.set_yticks(yticks[y_inds])

        # set tick labels based on scale
        if self.xscale == 'log':
            self.axis.set_xticklabels([r'$10^{%i}$' % int(i)
                                      for i in xticks[x_inds]], fontsize=self.x_tick_label_fontsize)
        else:
            self.axis.set_xticklabels([r'$%.3g$' % (i)
                                      for i in xticks[x_inds]], fontsize=self.x_tick_label_fontsize)

        if self.yscale == 'log':
            self.axis.set_yticklabels([r'$10^{%i}$' % int(i)
                                      for i in yticks[y_inds]], fontsize=self.y_tick_label_fontsize)
        else:
            self.axis.set_yticklabels([r'$%.3g$' % (i)
                                      for i in yticks[y_inds]], fontsize=self.y_tick_label_fontsize)

        # add grid
        if self.add_grid:
            self.axis.grid(True, linestyle='-', color='0.75')

        # add title
        if 'title' in self.__dict__.keys():
            self.axis.set_title(r'{}'.format(self.title), **self.title_kwargs)

        if 'xlabel' in self.__dict__.keys():
            self.axis.set_xlabel(r'{}'.format(self.xlabel), **self.xlabel_kwargs)

        if 'ylabel' in self.__dict__.keys():
            self.axis.set_ylabel(r'{}'.format(self.ylabel), **self.ylabel_kwargs)
        return
302722
function drawItemLabels(legend, barGroup) {
  // draw a subtle tick to help indicate what the label refers to
  function drawTick(y) {
    barGroup.appendChild(
      svgElement(
        legend,
        "line",
        {
          x1: legend.itemWidth,
          x2: legend.itemWidth + 5,
          y1: y,
          y2: y
        },
        "tick-mark"
      )
    );
  }

  function drawLabel(y, text) {
    var textOffsetX = 7;
    var textOffsetY = 3; // pixel shuffling to get the text to line up just right.
    barGroup.appendChild(
      svgElement(
        legend,
        "text",
        {
          x: legend.itemWidth + textOffsetX,
          y: y + textOffsetY
        },
        "item-label" + (legend.items.length > 6 ? "-small" : ""),
        text
      )
    );
  }

  legend.items.forEach(function(item, i) {
    var y = itemY(legend, i);
    if (defined(item.titleAbove)) {
      drawLabel(y, item.titleAbove);
      drawTick(y);
    }
    if (defined(item.title)) {
      drawLabel(y + legend.computedItemHeight / 2, item.title);
    }
    if (defined(item.titleBelow)) {
      drawLabel(y + legend.computedItemHeight, item.titleBelow);
      drawTick(y + legend.computedItemHeight);
    }
  });

  return itemY(legend, -1);
}
313872
def _visualize(self, x_label, y_labels, ticks, overlay, draw, annotate, width=6, height=4):
        
        for label in y_labels:
            if not all(isinstance(x, numbers.Real) for x in self[label]):
                raise ValueError("The column '{0}' contains non-numerical "
                    "values. A plot cannot be drawn for this column."
                    .format(label))

        n = len(y_labels)
        colors = list(itertools.islice(itertools.cycle(self.chart_colors), n))
        if overlay and n > 1:
            _, axis = plt.subplots(figsize=(width, height))
            if x_label is not None:
                axis.set_xlabel(x_label)
            for label, color in zip(y_labels, colors):
                draw(axis, label, color)
            if ticks is not None:
                annotate(axis, ticks)
            axis.legend(y_labels, loc=2, bbox_to_anchor=(1.05, 1))
            type(self).plots.append(axis)
        else:
            fig, axes = plt.subplots(n, 1, figsize=(width, height*n))
            if not isinstance(axes, collections.Iterable):
                axes=[axes]
            for axis, y_label, color in zip(axes, y_labels, colors):
                draw(axis, y_label, color)
                axis.set_ylabel(y_label, fontsize=16)
                if x_label is not None:
                    axis.set_xlabel(x_label, fontsize=16)
                if ticks is not None:
                    annotate(axis, ticks)
                type(self).plots.append(axis)