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)
| 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 | """ |