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

Method set_weight

lib/matplotlib/font_manager.py:974–997  ·  view source on GitHub ↗

Set the font weight. Parameters ---------- weight : int or {'ultralight', 'light', 'normal', 'regular', 'book', \ 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', \ 'extra bold', 'black'}, default: :rc:`font.weight` If int, must be in

(self, weight)

Source from the content-addressed store, hash-verified

972 self._variant = variant
973
974 def set_weight(self, weight):
975 """
976 Set the font weight.
977
978 Parameters
979 ----------
980 weight : int or {'ultralight', 'light', 'normal', 'regular', 'book', \
981'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', \
982'extra bold', 'black'}, default: :rc:`font.weight`
983 If int, must be in the range 0-1000.
984 """
985 weight = mpl._val_or_rc(weight, 'font.weight')
986 if weight in weight_dict:
987 self._weight = weight
988 return
989 try:
990 weight = int(weight)
991 except ValueError:
992 pass
993 else:
994 if 0 <= weight <= 1000:
995 self._weight = weight
996 return
997 raise ValueError(f"{weight=} is invalid")
998
999 def set_stretch(self, stretch):
1000 """

Callers 3

__init__Method · 0.95
set_fontweightMethod · 0.80

Calls

no outgoing calls