MCPcopy
hub / github.com/matplotlib/matplotlib / set_xlabel

Method set_xlabel

lib/matplotlib/axes/_base.py:3723–3771  ·  view source on GitHub ↗

Set the label for the x-axis. Parameters ---------- xlabel : str The label text. labelpad : float, default: :rc:`axes.labelpad` Spacing in points from the Axes bounding box including ticks and tick labels. If None, the p

(self, xlabel, fontdict=None, labelpad=None, *,
                   loc=None, **kwargs)

Source from the content-addressed store, hash-verified

3721 return label.get_text()
3722
3723 def set_xlabel(self, xlabel, fontdict=None, labelpad=None, *,
3724 loc=None, **kwargs):
3725 """
3726 Set the label for the x-axis.
3727
3728 Parameters
3729 ----------
3730 xlabel : str
3731 The label text.
3732
3733 labelpad : float, default: :rc:`axes.labelpad`
3734 Spacing in points from the Axes bounding box including ticks
3735 and tick labels. If None, the previous value is left as is.
3736
3737 loc : {'left', 'center', 'right'}, default: :rc:`xaxis.labellocation`
3738 The label position. This is a high-level alternative for passing
3739 parameters *x* and *horizontalalignment*.
3740
3741 Other Parameters
3742 ----------------
3743 **kwargs : `~matplotlib.text.Text` properties
3744 `.Text` properties control the appearance of the label.
3745
3746 See Also
3747 --------
3748 text : Documents the properties supported by `.Text`.
3749 """
3750 if labelpad is not None:
3751 self.xaxis.labelpad = labelpad
3752 protected_kw = ['x', 'horizontalalignment', 'ha']
3753 if {*kwargs} & {*protected_kw}:
3754 if loc is not None:
3755 raise TypeError(f"Specifying 'loc' is disallowed when any of "
3756 f"its corresponding low level keyword "
3757 f"arguments ({protected_kw}) are also "
3758 f"supplied")
3759
3760 else:
3761 loc = mpl._val_or_rc(loc, 'xaxis.labellocation')
3762 _api.check_in_list(('left', 'center', 'right'), loc=loc)
3763
3764 x = {
3765 'left': 0,
3766 'center': 0.5,
3767 'right': 1,
3768 }[loc]
3769 kwargs.update(x=x, horizontalalignment=loc)
3770
3771 return self.xaxis.set_label_text(xlabel, fontdict, **kwargs)
3772
3773 def invert_xaxis(self):
3774 """

Callers 15

_label_outer_xaxisMethod · 0.95
test_axes3d_reprFunction · 0.80
test_text3dFunction · 0.80
test_axes3d_labelpadFunction · 0.80
set_labelMethod · 0.80
autofmt_xdateMethod · 0.80
xlabelFunction · 0.80
psdMethod · 0.80
csdMethod · 0.80
magnitude_spectrumMethod · 0.80

Calls 2

set_label_textMethod · 0.80
updateMethod · 0.45

Tested by 15

test_axes3d_reprFunction · 0.64
test_text3dFunction · 0.64
test_axes3d_labelpadFunction · 0.64
test_bold_font_outputFunction · 0.64
_save_figureFunction · 0.64
test_label_without_ticksFunction · 0.64
test_keeping_xlabelFunction · 0.64
test_axhspanMethod · 0.64
test_axvspanMethod · 0.64