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

Skip to content

Improve docs of markers #17545

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
Jun 9, 2020
Merged
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
60 changes: 48 additions & 12 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@


class MarkerStyle:
"""
A class representing marker types.

Attributes
----------
markers : list
All known markers.
filled_markers : list
All known filled markers. This is a subset of *markers*.
fillstyles : list
The supported fillstyles.
"""

markers = {
'.': 'point',
Expand Down Expand Up @@ -202,18 +214,11 @@ class MarkerStyle:

def __init__(self, marker=None, fillstyle=None):
"""
Attributes
----------
markers : list of known marks

fillstyles : list of known fillstyles

filled_markers : list of known filled markers.

Parameters
----------
marker : str or array-like, default: None
See the descriptions of possible markers in the module docstring.
marker : str or array-like or None, default: None
*None* means no marker. For other possible marker values see the
module docstring `matplotlib.markers`.

fillstyle : str, default: 'full'
One of 'full', 'left', 'right', 'bottom', 'top', 'none'.
Expand Down Expand Up @@ -249,11 +254,13 @@ def get_fillstyle(self):

def set_fillstyle(self, fillstyle):
"""
Sets fillstyle
Set the fillstyle.

Parameters
----------
fillstyle : string amongst known fillstyles
fillstyle : {'full', 'left', 'right', 'bottom', 'top', 'none'}
The part of the marker surface that is colored with
markerfacecolor.
"""
if fillstyle is None:
fillstyle = rcParams['markers.fillstyle']
Expand All @@ -271,6 +278,15 @@ def get_marker(self):
return self._marker

def set_marker(self, marker):
"""
Set the marker.

Parameters
----------
marker : str or array-like or None, default: None
*None* means no marker. For other possible marker values see the
module docstring `matplotlib.markers`.
"""
if (isinstance(marker, np.ndarray) and marker.ndim == 2 and
marker.shape[1] == 2):
self._marker_function = self._set_vertices
Expand Down Expand Up @@ -300,15 +316,35 @@ def set_marker(self, marker):
self._recache()

def get_path(self):
"""
Return a `.Path` for the primary part of the marker.

For unfilled markers this is the whole marker, for filled markers,
this is the area to be drawn with *markerfacecolor*.
"""
return self._path

def get_transform(self):
"""
Return the transform to be applied to the `.Path` from
`MarkerStyle.get_path()`.
Comment on lines +329 to +330
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't pydocstyle be complaining that the first line should only be one line, or do we have that turned off?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would be

D400 - First line should end with a period

We have currently deactivated that in .flake8 because we have a couple of docstrings that can't reasonably be cramped into 79 chars.

While it's good to keep the summary sentence short, personally, I don't see the point in stripping relevant information from the summary only to adhere to that limit. If you have an idea how to shorten the sentence meaningfully to a single line, that'd of course be welcome.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the transform ones, but the get_alt_path one could be written like get_path.

Copy link
Member Author

@timhoffm timhoffm Jun 7, 2020

Choose a reason for hiding this comment

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

get_alt_path updated. I have no good idea for wording of the transforms, so I'd leave them pointing to the paths.

"""
return self._transform.frozen()

def get_alt_path(self):
"""
Return a `.Path` for the alternate part of the marker.

For unfilled markers, this is *None*; for filled markers, this is the
area to be drawn with *markerfacecoloralt*.
"""
return self._alt_path

def get_alt_transform(self):
"""
Return the transform to be applied to the `.Path` from
`MarkerStyle.get_alt_path()`.
"""
return self._alt_transform.frozen()

def get_snap_threshold(self):
Expand Down