Skip to content

Commit b47fd63

Browse files
authored
Merge pull request #11938 from timhoffm/doc-line2d-part2
More docstring cleanup of Line2D.
2 parents f95b8ba + 376e577 commit b47fd63

File tree

2 files changed

+112
-21
lines changed

2 files changed

+112
-21
lines changed

lib/matplotlib/artist.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,17 @@ def set_agg_filter(self, filter_func):
828828
self.stale = True
829829

830830
def draw(self, renderer, *args, **kwargs):
831-
'Derived classes drawing method'
831+
"""
832+
Draw the Artist using the given renderer.
833+
834+
This method will be overridden in the Artist subclasses. Typically,
835+
it is implemented to not have any effect if the Artist is not visible
836+
(`.Artist.get_visible` is *False*).
837+
838+
Parameters
839+
----------
840+
renderer : `.RendererBase` subclass.
841+
"""
832842
if not self.get_visible():
833843
return
834844
self.stale = False

lib/matplotlib/lines.py

Lines changed: 101 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,18 @@ def contains(self, mouseevent):
436436
:meth:`~matplotlib.lines.Line2D.set_pickradius` to view or
437437
modify it.
438438
439-
Returns *True* if any values are within the radius along with
440-
``{'ind': pointlist}``, where *pointlist* is the set of points
441-
within the radius.
439+
Parameters
440+
----------
441+
mouseevent : `matplotlib.backend_bases.MouseEvent`.
442442
443-
TODO: sort returned indices by distance
443+
Returns
444+
-------
445+
contains : bool
446+
Whether any values are within the radius.
447+
``{'ind': pointlist}``
448+
Where *pointlist* is the set of points within the radius.
449+
450+
TODO: sort returned indices by distance
444451
"""
445452
if callable(self._contains):
446453
return self._contains(self, mouseevent)
@@ -492,12 +499,18 @@ def contains(self, mouseevent):
492499
return len(ind) > 0, dict(ind=ind)
493500

494501
def get_pickradius(self):
495-
"""Return the pick radius used for containment tests."""
502+
"""
503+
Return the pick radius used for containment tests.
504+
505+
See `.contains` for more details.
506+
"""
496507
return self.pickradius
497508

498509
def set_pickradius(self, d):
499510
"""Set the pick radius used for containment tests.
500511
512+
See `.contains` for more details.
513+
501514
Parameters
502515
----------
503516
d : float
@@ -507,7 +520,9 @@ def set_pickradius(self, d):
507520

508521
def get_fillstyle(self):
509522
"""
510-
Return the marker fillstyle.
523+
Return the marker fill style.
524+
525+
See also `~.Line2D.set_fillstyle`.
511526
"""
512527
return self._marker.get_fillstyle()
513528

@@ -585,7 +600,11 @@ def set_markevery(self, every):
585600
self._markevery = every
586601

587602
def get_markevery(self):
588-
"""Return the markevery setting."""
603+
"""
604+
Return the markevery setting for marker subsampling.
605+
606+
See also `~.Line2D.set_markevery`.
607+
"""
589608
return self._markevery
590609

591610
def set_picker(self, p):
@@ -715,7 +734,7 @@ def set_transform(self, t):
715734
716735
Parameters
717736
----------
718-
t : matplotlib.transforms.Transform
737+
t : `matplotlib.transforms.Transform`
719738
"""
720739
Artist.set_transform(self, t)
721740
self._invalidx = True
@@ -729,7 +748,8 @@ def _is_sorted(self, x):
729748

730749
@allow_rasterization
731750
def draw(self, renderer):
732-
"""Draw the Line with *renderer* unless visibility is *False*."""
751+
# docstring inherited from Artist.draw.
752+
733753
if not self.get_visible():
734754
return
735755

@@ -864,22 +884,51 @@ def get_antialiased(self):
864884
return self._antialiased
865885

866886
def get_color(self):
867-
"""Return the line color."""
887+
"""
888+
Return the line color.
889+
890+
See also `~.Line2D.set_color`.
891+
"""
868892
return self._color
869893

870894
def get_drawstyle(self):
895+
"""
896+
Return the drawstyle.
897+
898+
See also `~.Line2D.set_drawstyle`.
899+
"""
871900
return self._drawstyle
872901

873902
def get_linestyle(self):
903+
"""
904+
Return the linestyle.
905+
906+
See also `~.Line2D.set_linestyle`.
907+
"""
874908
return self._linestyle
875909

876910
def get_linewidth(self):
911+
"""
912+
Return the linewidth in points.
913+
914+
See also `~.Line2D.set_linewidth`.
915+
"""
877916
return self._linewidth
878917

879918
def get_marker(self):
919+
"""
920+
Return the line marker.
921+
922+
See also `~.Line2D.set_marker`.
923+
"""
880924
return self._marker.get_marker()
881925

882926
def get_markeredgecolor(self):
927+
"""
928+
Return the marker edge color.
929+
930+
See also `~.Line2D.set_markeredgecolor`.
931+
"""
883932
mec = self._markeredgecolor
884933
if cbook._str_equal(mec, 'auto'):
885934
if rcParams['_internal.classic_mode']:
@@ -892,6 +941,11 @@ def get_markeredgecolor(self):
892941
return mec
893942

894943
def get_markeredgewidth(self):
944+
"""
945+
Return the marker edge width in points.
946+
947+
See also `~.Line2D.set_markeredgewidth`.
948+
"""
895949
return self._markeredgewidth
896950

897951
def _get_markerfacecolor(self, alt=False):
@@ -905,12 +959,27 @@ def _get_markerfacecolor(self, alt=False):
905959
return fc
906960

907961
def get_markerfacecolor(self):
962+
"""
963+
Return the marker face color.
964+
965+
See also `~.Line2D.set_markerfacecolor`.
966+
"""
908967
return self._get_markerfacecolor(alt=False)
909968

910969
def get_markerfacecoloralt(self):
970+
"""
971+
Return the alternate marker face color.
972+
973+
See also `~.Line2D.set_markerfacecoloralt`.
974+
"""
911975
return self._get_markerfacecolor(alt=True)
912976

913977
def get_markersize(self):
978+
"""
979+
Return the marker size in points.
980+
981+
See also `~.Line2D.set_markersize`.
982+
"""
914983
return self._markersize
915984

916985
def get_data(self, orig=True):
@@ -1252,7 +1321,7 @@ def set_dashes(self, seq):
12521321
self.set_linestyle((0, seq))
12531322

12541323
def update_from(self, other):
1255-
"""copy properties from other to self"""
1324+
"""Copy properties from other to self."""
12561325
Artist.update_from(self, other)
12571326
self._linestyle = other._linestyle
12581327
self._linewidth = other._linewidth
@@ -1278,7 +1347,7 @@ def update_from(self, other):
12781347

12791348
def set_dash_joinstyle(self, s):
12801349
"""
1281-
Set the join style for dashed linestyles.
1350+
Set the join style for dashed lines.
12821351
12831352
Parameters
12841353
----------
@@ -1295,7 +1364,7 @@ def set_dash_joinstyle(self, s):
12951364

12961365
def set_solid_joinstyle(self, s):
12971366
"""
1298-
Set the join style for solid linestyles.
1367+
Set the join style for solid lines.
12991368
13001369
Parameters
13011370
----------
@@ -1313,19 +1382,23 @@ def set_solid_joinstyle(self, s):
13131382

13141383
def get_dash_joinstyle(self):
13151384
"""
1316-
Get the join style for dashed linestyles.
1385+
Return the join style for dashed lines.
1386+
1387+
See also `~.Line2D.set_dash_joinstyle`.
13171388
"""
13181389
return self._dashjoinstyle
13191390

13201391
def get_solid_joinstyle(self):
13211392
"""
1322-
Get the join style for solid linestyles.
1393+
Return the join style for solid lines.
1394+
1395+
See also `~.Line2D.set_solid_joinstyle`.
13231396
"""
13241397
return self._solidjoinstyle
13251398

13261399
def set_dash_capstyle(self, s):
13271400
"""
1328-
Set the cap style for dashed linestyles.
1401+
Set the cap style for dashed lines.
13291402
13301403
Parameters
13311404
----------
@@ -1341,7 +1414,7 @@ def set_dash_capstyle(self, s):
13411414

13421415
def set_solid_capstyle(self, s):
13431416
"""
1344-
Set the cap style for solid linestyles.
1417+
Set the cap style for solid lines.
13451418
13461419
Parameters
13471420
----------
@@ -1357,18 +1430,26 @@ def set_solid_capstyle(self, s):
13571430

13581431
def get_dash_capstyle(self):
13591432
"""
1360-
Get the cap style for dashed linestyles.
1433+
Return the cap style for dashed lines.
1434+
1435+
See also `~.Line2D.set_dash_capstyle`.
13611436
"""
13621437
return self._dashcapstyle
13631438

13641439
def get_solid_capstyle(self):
13651440
"""
1366-
Get the cap style for solid linestyles.
1441+
Return the cap style for solid lines.
1442+
1443+
See also `~.Line2D.set_solid_capstyle`.
13671444
"""
13681445
return self._solidcapstyle
13691446

13701447
def is_dashed(self):
1371-
"""Return whether line is dashstyle."""
1448+
"""
1449+
Return whether line has a dashed linestyle.
1450+
1451+
See also `~.Line2D.set_linestyle`.
1452+
"""
13721453
return self._linestyle in ('--', '-.', ':')
13731454

13741455

0 commit comments

Comments
 (0)