Skip to content

More docstring cleanup of Line2D. #11938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,17 @@ def set_agg_filter(self, filter_func):
self.stale = True

def draw(self, renderer, *args, **kwargs):
'Derived classes drawing method'
"""
Draw the Artist using the given renderer.

This method will be overridden in the Artist subclasses. Typically,
it is implemented to not have any effect if the Artist is not visible
(`.Artist.get_visible` is *False*).

Parameters
----------
renderer : `.RendererBase` subclass.
"""
if not self.get_visible():
return
self.stale = False
Expand Down
121 changes: 101 additions & 20 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,18 @@ def contains(self, mouseevent):
:meth:`~matplotlib.lines.Line2D.set_pickradius` to view or
modify it.

Returns *True* if any values are within the radius along with
``{'ind': pointlist}``, where *pointlist* is the set of points
within the radius.
Parameters
----------
mouseevent : `matplotlib.backend_bases.MouseEvent`.

TODO: sort returned indices by distance
Returns
-------
contains : bool
Whether any values are within the radius.
``{'ind': pointlist}``
Where *pointlist* is the set of points within the radius.

TODO: sort returned indices by distance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave this out of the docstring? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's been in there before. I didn't bother to decide if this should stay or be moved to a comment or be deleted completely.

Just checked: It's a comment by John D. Hunter from 2007. Anyone thinks this is still relevant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just leave it in for now, didn't notice it was already there.

"""
if callable(self._contains):
return self._contains(self, mouseevent)
Expand Down Expand Up @@ -492,12 +499,18 @@ def contains(self, mouseevent):
return len(ind) > 0, dict(ind=ind)

def get_pickradius(self):
"""Return the pick radius used for containment tests."""
"""
Return the pick radius used for containment tests.

See `.contains` for more details.
"""
return self.pickradius

def set_pickradius(self, d):
"""Set the pick radius used for containment tests.

See `.contains` for more details.

Parameters
----------
d : float
Expand All @@ -507,7 +520,9 @@ def set_pickradius(self, d):

def get_fillstyle(self):
"""
Return the marker fillstyle.
Return the marker fill style.

See also `~.Line2D.set_fillstyle`.
"""
return self._marker.get_fillstyle()

Expand Down Expand Up @@ -585,7 +600,11 @@ def set_markevery(self, every):
self._markevery = every

def get_markevery(self):
"""Return the markevery setting."""
"""
Return the markevery setting for marker subsampling.

See also `~.Line2D.set_markevery`.
"""
return self._markevery

def set_picker(self, p):
Expand Down Expand Up @@ -715,7 +734,7 @@ def set_transform(self, t):

Parameters
----------
t : matplotlib.transforms.Transform
t : `matplotlib.transforms.Transform`
"""
Artist.set_transform(self, t)
self._invalidx = True
Expand All @@ -729,7 +748,8 @@ def _is_sorted(self, x):

@allow_rasterization
def draw(self, renderer):
"""Draw the Line with *renderer* unless visibility is *False*."""
# docstring inherited from Artist.draw.

if not self.get_visible():
return

Expand Down Expand Up @@ -864,22 +884,51 @@ def get_antialiased(self):
return self._antialiased

def get_color(self):
"""Return the line color."""
"""
Return the line color.

See also `~.Line2D.set_color`.
"""
return self._color

def get_drawstyle(self):
"""
Return the drawstyle.

See also `~.Line2D.set_drawstyle`.
"""
return self._drawstyle

def get_linestyle(self):
"""
Return the linestyle.

See also `~.Line2D.set_linestyle`.
"""
return self._linestyle

def get_linewidth(self):
"""
Return the linewidth in points.

See also `~.Line2D.set_linewidth`.
"""
return self._linewidth

def get_marker(self):
"""
Return the line marker.

See also `~.Line2D.set_marker`.
"""
return self._marker.get_marker()

def get_markeredgecolor(self):
"""
Return the marker edge color.

See also `~.Line2D.set_markeredgecolor`.
"""
mec = self._markeredgecolor
if cbook._str_equal(mec, 'auto'):
if rcParams['_internal.classic_mode']:
Expand All @@ -892,6 +941,11 @@ def get_markeredgecolor(self):
return mec

def get_markeredgewidth(self):
"""
Return the marker edge width in points.

See also `~.Line2D.set_markeredgewidth`.
"""
return self._markeredgewidth

def _get_markerfacecolor(self, alt=False):
Expand All @@ -905,12 +959,27 @@ def _get_markerfacecolor(self, alt=False):
return fc

def get_markerfacecolor(self):
"""
Return the marker face color.

See also `~.Line2D.set_markerfacecolor`.
"""
return self._get_markerfacecolor(alt=False)

def get_markerfacecoloralt(self):
"""
Return the alternate marker face color.

See also `~.Line2D.set_markerfacecoloralt`.
"""
return self._get_markerfacecolor(alt=True)

def get_markersize(self):
"""
Return the marker size in points.

See also `~.Line2D.set_markersize`.
"""
return self._markersize

def get_data(self, orig=True):
Expand Down Expand Up @@ -1252,7 +1321,7 @@ def set_dashes(self, seq):
self.set_linestyle((0, seq))

def update_from(self, other):
"""copy properties from other to self"""
"""Copy properties from other to self."""
Artist.update_from(self, other)
self._linestyle = other._linestyle
self._linewidth = other._linewidth
Expand All @@ -1278,7 +1347,7 @@ def update_from(self, other):

def set_dash_joinstyle(self, s):
"""
Set the join style for dashed linestyles.
Set the join style for dashed lines.

Parameters
----------
Expand All @@ -1295,7 +1364,7 @@ def set_dash_joinstyle(self, s):

def set_solid_joinstyle(self, s):
"""
Set the join style for solid linestyles.
Set the join style for solid lines.

Parameters
----------
Expand All @@ -1313,19 +1382,23 @@ def set_solid_joinstyle(self, s):

def get_dash_joinstyle(self):
"""
Get the join style for dashed linestyles.
Return the join style for dashed lines.

See also `~.Line2D.set_dash_joinstyle`.
"""
return self._dashjoinstyle

def get_solid_joinstyle(self):
"""
Get the join style for solid linestyles.
Return the join style for solid lines.

See also `~.Line2D.set_solid_joinstyle`.
"""
return self._solidjoinstyle

def set_dash_capstyle(self, s):
"""
Set the cap style for dashed linestyles.
Set the cap style for dashed lines.

Parameters
----------
Expand All @@ -1341,7 +1414,7 @@ def set_dash_capstyle(self, s):

def set_solid_capstyle(self, s):
"""
Set the cap style for solid linestyles.
Set the cap style for solid lines.

Parameters
----------
Expand All @@ -1357,18 +1430,26 @@ def set_solid_capstyle(self, s):

def get_dash_capstyle(self):
"""
Get the cap style for dashed linestyles.
Return the cap style for dashed lines.

See also `~.Line2D.set_dash_capstyle`.
"""
return self._dashcapstyle

def get_solid_capstyle(self):
"""
Get the cap style for solid linestyles.
Return the cap style for solid lines.

See also `~.Line2D.set_solid_capstyle`.
"""
return self._solidcapstyle

def is_dashed(self):
"""Return whether line is dashstyle."""
"""
Return whether line has a dashed linestyle.

See also `~.Line2D.set_linestyle`.
"""
return self._linestyle in ('--', '-.', ':')


Expand Down