Set the linestyle of the line. Parameters ---------- ls : {'-', '--', '-.', ':', '', ...} or (offset, on-off-seq) Possible values: - A string: ======================================================= ================
(self, ls)
| 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): |