MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_ylabel

Method set_ylabel

lib/matplotlib/axes/_base.py:3991–4039  ·  view source on GitHub ↗

Set the label for the y-axis. Parameters ---------- ylabel : 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, ylabel, fontdict=None, labelpad=None, *,
                   loc=None, **kwargs)

Source from the content-addressed store, hash-verified

3989 return label.get_text()
3990
3991 def set_ylabel(self, ylabel, fontdict=None, labelpad=None, *,
3992 loc=None, **kwargs):
3993 """
3994 Set the label for the y-axis.
3995
3996 Parameters
3997 ----------
3998 ylabel : str
3999 The label text.
4000
4001 labelpad : float, default: :rc:`axes.labelpad`
4002 Spacing in points from the Axes bounding box including ticks
4003 and tick labels. If None, the previous value is left as is.
4004
4005 loc : {'bottom', 'center', 'top'}, default: :rc:`yaxis.labellocation`
4006 The label position. This is a high-level alternative for passing
4007 parameters *y* and *horizontalalignment*.
4008
4009 Other Parameters
4010 ----------------
4011 **kwargs : `~matplotlib.text.Text` properties
4012 `.Text` properties control the appearance of the label.
4013
4014 See Also
4015 --------
4016 text : Documents the properties supported by `.Text`.
4017 """
4018 if labelpad is not None:
4019 self.yaxis.labelpad = labelpad
4020 protected_kw = ['y', 'horizontalalignment', 'ha']
4021 if {*kwargs} & {*protected_kw}:
4022 if loc is not None:
4023 raise TypeError(f"Specifying 'loc' is disallowed when any of "
4024 f"its corresponding low level keyword "
4025 f"arguments ({protected_kw}) are also "
4026 f"supplied")
4027
4028 else:
4029 loc = mpl._val_or_rc(loc, 'yaxis.labellocation')
4030 _api.check_in_list(('bottom', 'center', 'top'), loc=loc)
4031
4032 y, ha = {
4033 'bottom': (0, 'left'),
4034 'center': (0.5, 'center'),
4035 'top': (1, 'right')
4036 }[loc]
4037 kwargs.update(y=y, horizontalalignment=ha)
4038
4039 return self.yaxis.set_label_text(ylabel, fontdict, **kwargs)
4040
4041 def invert_yaxis(self):
4042 """

Callers 15

_label_outer_yaxisMethod · 0.95
run_memleak_testFunction · 0.80
test_axes3d_reprFunction · 0.80
test_text3dFunction · 0.80
test_axes3d_labelpadFunction · 0.80
test_axis_artistFunction · 0.80
test_SubplotZeroFunction · 0.80
test_SubplotFunction · 0.80
set_labelMethod · 0.80
ylabelFunction · 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_axis_artistFunction · 0.64
test_SubplotZeroFunction · 0.64
test_SubplotFunction · 0.64
test_bold_font_outputFunction · 0.64
_save_figureFunction · 0.64
test_label_without_ticksFunction · 0.64