Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4b4567

Browse files
committed
Improve docstrings of Line2D
1 parent d384595 commit b4b4567

File tree

1 file changed

+80
-54
lines changed

1 file changed

+80
-54
lines changed

lib/matplotlib/lines.py

Lines changed: 80 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def contains(self, mouseevent):
492492
return len(ind) > 0, dict(ind=ind)
493493

494494
def get_pickradius(self):
495-
"""return the pick radius used for containment tests"""
495+
"""Return the pick radius used for containment tests."""
496496
return self.pickradius
497497

498498
def set_pickradius(self, d):
@@ -507,18 +507,27 @@ def set_pickradius(self, d):
507507

508508
def get_fillstyle(self):
509509
"""
510-
return the marker fillstyle
510+
Return the marker fillstyle.
511511
"""
512512
return self._marker.get_fillstyle()
513513

514514
def set_fillstyle(self, fs):
515515
"""
516-
Set the marker fill style; 'full' means fill the whole marker.
517-
'none' means no filling; other options are for half-filled markers.
516+
Set the marker fill style.
518517
519518
Parameters
520519
----------
521520
fs : {'full', 'left', 'right', 'bottom', 'top', 'none'}
521+
Possible values:
522+
523+
- 'full': Fill the whole marker with the *markerfacecolor*.
524+
- 'left', 'right', 'bottom', 'top': Fill the marker half at
525+
the given side with the *markerfacecolor*. The other
526+
half of the marker is filled with *markerfacecoloralt*.
527+
- 'none': No filling.
528+
529+
For examples see
530+
:doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`.
522531
"""
523532
self._marker.set_fillstyle(fs)
524533
self.stale = True
@@ -576,7 +585,7 @@ def set_markevery(self, every):
576585
self._markevery = every
577586

578587
def get_markevery(self):
579-
"""return the markevery setting"""
588+
"""Return the markevery setting."""
580589
return self._markevery
581590

582591
def set_picker(self, p):
@@ -619,7 +628,7 @@ def axes(self, ax):
619628

620629
def set_data(self, *args):
621630
"""
622-
Set the x and y data
631+
Set the x and y data.
623632
624633
ACCEPTS: 2D array (rows are x, y) or two 1D arrays
625634
"""
@@ -702,7 +711,7 @@ def _get_transformed_path(self):
702711

703712
def set_transform(self, t):
704713
"""
705-
set the Transformation instance used by this artist
714+
Set the Transformation instance used by this artist.
706715
707716
Parameters
708717
----------
@@ -714,13 +723,13 @@ def set_transform(self, t):
714723
self.stale = True
715724

716725
def _is_sorted(self, x):
717-
"""return True if x is sorted in ascending order"""
726+
"""Return whether x is sorted in ascending order."""
718727
# We don't handle the monotonically decreasing case.
719728
return _path.is_sorted(x)
720729

721730
@allow_rasterization
722731
def draw(self, renderer):
723-
"""draw the Line with `renderer` unless visibility is False"""
732+
"""Draw the Line with *renderer* unless visibility is *False*."""
724733
if not self.get_visible():
725734
return
726735

@@ -851,9 +860,11 @@ def draw(self, renderer):
851860
self.stale = False
852861

853862
def get_antialiased(self):
863+
"""Return whether antialiased rendering is used."""
854864
return self._antialiased
855865

856866
def get_color(self):
867+
"""Return the line color."""
857868
return self._color
858869

859870
def get_drawstyle(self):
@@ -967,7 +978,7 @@ def set_antialiased(self, b):
967978

968979
def set_color(self, color):
969980
"""
970-
Set the color of the line
981+
Set the color of the line.
971982
972983
Parameters
973984
----------
@@ -978,16 +989,27 @@ def set_color(self, color):
978989

979990
def set_drawstyle(self, drawstyle):
980991
"""
981-
Set the drawstyle of the plot
992+
Set the drawstyle of the plot.
982993
983-
'default' connects the points with lines. The steps variants
984-
produce step-plots. 'steps' is equivalent to 'steps-pre' and
985-
is maintained for backward-compatibility.
994+
The drawstyle determines how the points are connected.
986995
987996
Parameters
988997
----------
989998
drawstyle : {'default', 'steps', 'steps-pre', 'steps-mid', \
990999
'steps-post'}
1000+
Possible values:
1001+
1002+
- 'default': The points are connected with straight lines.
1003+
- 'steps-pre', 'steps-mid', 'steps-post': The points are
1004+
connected with step-like lines, i.e. horizontal lines with
1005+
vertical steps.
1006+
The postfix pre/mid/post determines the position of the vertical
1007+
step (before the line segment, i.e. directly after the left
1008+
point / halfway between the points / after the line segment,
1009+
i.e. directly before the right point).
1010+
- 'steps' is equal to 'steps-pre' and is maintained for
1011+
backward-compatibility.
1012+
9911013
"""
9921014
if drawstyle is None:
9931015
drawstyle = 'default'
@@ -1001,7 +1023,7 @@ def set_drawstyle(self, drawstyle):
10011023

10021024
def set_linewidth(self, w):
10031025
"""
1004-
Set the line width in points
1026+
Set the line width in points.
10051027
10061028
Parameters
10071029
----------
@@ -1017,9 +1039,10 @@ def set_linewidth(self, w):
10171039
self._us_dashOffset, self._us_dashSeq, self._linewidth)
10181040

10191041
def _split_drawstyle_linestyle(self, ls):
1020-
'''Split drawstyle from linestyle string
1042+
"""
1043+
Split drawstyle from linestyle string.
10211044
1022-
If `ls` is only a drawstyle default to returning a linestyle
1045+
If *ls* is only a drawstyle default to returning a linestyle
10231046
of '-'.
10241047
10251048
Parameters
@@ -1035,48 +1058,43 @@ def _split_drawstyle_linestyle(self, ls):
10351058
10361059
ls : str
10371060
The linestyle with the drawstyle (if any) stripped.
1038-
'''
1061+
"""
10391062
for ds in self.drawStyleKeys: # long names are first in the list
10401063
if ls.startswith(ds):
10411064
return ds, ls[len(ds):] or '-'
10421065
return None, ls
10431066

10441067
def set_linestyle(self, ls):
10451068
"""
1046-
Set the linestyle of the line (also accepts drawstyles,
1047-
e.g., ``'steps--'``)
1048-
1049-
1050-
=========================== =================
1051-
linestyle description
1052-
=========================== =================
1053-
``'-'`` or ``'solid'`` solid line
1054-
``'--'`` or ``'dashed'`` dashed line
1055-
``'-.'`` or ``'dashdot'`` dash-dotted line
1056-
``':'`` or ``'dotted'`` dotted line
1057-
``'None'`` draw nothing
1058-
``' '`` draw nothing
1059-
``''`` draw nothing
1060-
=========================== =================
1069+
Set the linestyle of the line.
10611070
1062-
'steps' is equivalent to 'steps-pre' and is maintained for
1063-
backward-compatibility.
1071+
Parameters
1072+
----------
1073+
ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
1074+
Possible values:
10641075
1065-
Alternatively a dash tuple of the following form can be provided::
1076+
- A string:
10661077
1067-
(offset, onoffseq),
1078+
=============================== =================
1079+
Linestyle Description
1080+
=============================== =================
1081+
``'-'`` or ``'solid'`` solid line
1082+
``'--'`` or ``'dashed'`` dashed line
1083+
``'-.'`` or ``'dashdot'`` dash-dotted line
1084+
``':'`` or ``'dotted'`` dotted line
1085+
``'None'`` or ``' '`` or ``''`` draw nothing
1086+
=============================== =================
10681087
1069-
where ``onoffseq`` is an even length tuple of on and off ink in points.
1088+
Optionally, the string may be preceded by a drawstyle, e.g.
1089+
``'steps--'``. See :meth:`set_drawstyle` for details.
10701090
1071-
.. seealso::
1091+
- Alternatively a dash tuple of the following form can be
1092+
provided::
10721093
1073-
:meth:`set_drawstyle`
1074-
To set the drawing style (stepping) of the plot.
1094+
(offset, onoffseq)
10751095
1076-
Parameters
1077-
----------
1078-
ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
1079-
The line style.
1096+
where ``onoffseq`` is an even length tuple of on and off ink
1097+
in points. See also :meth:`set_dashes`.
10801098
"""
10811099
if isinstance(ls, str):
10821100
ds, ls = self._split_drawstyle_linestyle(ls)
@@ -1110,7 +1128,7 @@ def set_marker(self, marker):
11101128
11111129
Parameters
11121130
----------
1113-
marker: marker style
1131+
marker : marker style
11141132
See `~matplotlib.markers` for full description of possible
11151133
arguments.
11161134
"""
@@ -1213,13 +1231,19 @@ def set_ydata(self, y):
12131231

12141232
def set_dashes(self, seq):
12151233
"""
1216-
Set the dash sequence, sequence of dashes with on off ink in
1217-
points. If seq is empty or if seq = (None, None), the
1218-
linestyle will be set to solid.
1234+
Set the dash sequence.
1235+
1236+
The dash sequence is a sequence of floats of even length describing
1237+
the length of dashes and spaces in points.
1238+
1239+
For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point
1240+
dashes separated by 2 point spaces.
12191241
12201242
Parameters
12211243
----------
12221244
seq : sequence of floats (on/off ink in points) or (None, None)
1245+
If *seq* is empty or ``(None, None)``, the linestyle will be set
1246+
to solid.
12231247
"""
12241248
if seq == (None, None) or len(seq) == 0:
12251249
self.set_linestyle('-')
@@ -1258,6 +1282,7 @@ def set_dash_joinstyle(self, s):
12581282
Parameters
12591283
----------
12601284
s : {'miter', 'round', 'bevel'}
1285+
For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
12611286
"""
12621287
s = s.lower()
12631288
if s not in self.validJoin:
@@ -1274,6 +1299,7 @@ def set_solid_joinstyle(self, s):
12741299
Parameters
12751300
----------
12761301
s : {'miter', 'round', 'bevel'}
1302+
For examples see :doc:`/gallery/lines_bars_and_markers/joinstyle`.
12771303
"""
12781304
s = s.lower()
12791305
if s not in self.validJoin:
@@ -1286,13 +1312,13 @@ def set_solid_joinstyle(self, s):
12861312

12871313
def get_dash_joinstyle(self):
12881314
"""
1289-
Get the join style for dashed linestyles
1315+
Get the join style for dashed linestyles.
12901316
"""
12911317
return self._dashjoinstyle
12921318

12931319
def get_solid_joinstyle(self):
12941320
"""
1295-
Get the join style for solid linestyles
1321+
Get the join style for solid linestyles.
12961322
"""
12971323
return self._solidjoinstyle
12981324

@@ -1330,18 +1356,18 @@ def set_solid_capstyle(self, s):
13301356

13311357
def get_dash_capstyle(self):
13321358
"""
1333-
Get the cap style for dashed linestyles
1359+
Get the cap style for dashed linestyles.
13341360
"""
13351361
return self._dashcapstyle
13361362

13371363
def get_solid_capstyle(self):
13381364
"""
1339-
Get the cap style for solid linestyles
1365+
Get the cap style for solid linestyles.
13401366
"""
13411367
return self._solidcapstyle
13421368

13431369
def is_dashed(self):
1344-
'return True if line is dashstyle'
1370+
"""Return whether line is dashstyle."""
13451371
return self._linestyle in ('--', '-.', ':')
13461372

13471373

0 commit comments

Comments
 (0)