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

Method set_linestyle

lib/matplotlib/lines.py:1160–1213  ·  view source on GitHub ↗

Set the linestyle of the line. Parameters ---------- ls : {'-', '--', '-.', ':', '', ...} or (offset, on-off-seq) Possible values: - A string: ======================================================= ================

(self, ls)

Source from the content-addressed store, hash-verified

1158 self._dash_pattern = _scale_dashes(*self._unscaled_dash_pattern, w)
1159
1160 def set_linestyle(self, ls):
1161 """
1162 Set the linestyle of the line.
1163
1164 Parameters
1165 ----------
1166 ls : {'-', '--', '-.', ':', '', ...} or (offset, on-off-seq)
1167 Possible values:
1168
1169 - A string:
1170
1171 ======================================================= ================
1172 linestyle description
1173 ======================================================= ================
1174 ``'-'`` or ``'solid'`` solid line
1175 ``'--'`` or ``'dashed'`` dashed line
1176 ``'-.'`` or ``'dashdot'`` dash-dotted line
1177 ``':'`` or ``'dotted'`` dotted line
1178 ``''`` or ``'none'`` (discouraged: ``'None'``, ``' '``) draw nothing
1179 ======================================================= ================
1180
1181 - A tuple describing the start position and lengths of dashes and spaces:
1182
1183 (offset, onoffseq)
1184
1185 where
1186
1187 - *offset* is a float specifying the offset (in points); i.e. how much
1188 is the dash pattern shifted.
1189 - *onoffseq* is a sequence of on and off ink in points. There can be
1190 arbitrary many pairs of on and off values.
1191
1192 Example: The tuple ``(0, (10, 5, 1, 5))`` means that the pattern starts
1193 at the beginning of the line. It draws a 10 point long dash,
1194 then a 5 point long space, then a 1 point long dash, followed by a 5 point
1195 long space, and then the pattern repeats.
1196
1197 See also :meth:`set_dashes`.
1198
1199 For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
1200 """
1201 if isinstance(ls, str):
1202 if ls in [' ', '', 'none']:
1203 ls = 'None'
1204 _api.check_in_list([*self._lineStyles, *ls_mapper_r], ls=ls)
1205 if ls not in self._lineStyles:
1206 ls = ls_mapper_r[ls]
1207 self._linestyle = ls
1208 else:
1209 self._linestyle = '--'
1210 self._unscaled_dash_pattern = _get_dash_pattern(ls)
1211 self._dash_pattern = _scale_dashes(
1212 *self._unscaled_dash_pattern, self._linewidth)
1213 self.stale = True
1214
1215 @_docstring.interpd
1216 def set_marker(self, marker):

Callers 15

__init__Method · 0.95
set_dashesMethod · 0.95
create_artistsMethod · 0.95
create_artistsMethod · 0.95
test_valid_linestylesFunction · 0.95
_tick_update_positionFunction · 0.45
draw_gridMethod · 0.45
_default_update_propMethod · 0.45
_update_propMethod · 0.45
apply_callbackFunction · 0.45

Calls 2

_get_dash_patternFunction · 0.85
_scale_dashesFunction · 0.85