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

Skip to content

Commit 243d78d

Browse files
committed
Fix docstrings about refactored markers.
1 parent 83da58e commit 243d78d

3 files changed

Lines changed: 48 additions & 44 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5652,33 +5652,7 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
56525652
*marker*:
56535653
can be one of:
56545654
5655-
# TODO: Use documentation in MarkerStyle
5656-
5657-
The marker can also be a tuple (*numsides*, *style*,
5658-
*angle*), which will create a custom, regular symbol.
5659-
5660-
*numsides*:
5661-
the number of sides
5662-
5663-
*style*:
5664-
the style of the regular symbol:
5665-
5666-
===== =============================================
5667-
Value Description
5668-
===== =============================================
5669-
0 a regular polygon
5670-
1 a star-like symbol
5671-
2 an asterisk
5672-
3 a circle (*numsides* and *angle* is ignored)
5673-
===== =============================================
5674-
5675-
*angle*:
5676-
the angle of rotation of the symbol
5677-
5678-
Finally, *marker* can be (*verts*, 0): *verts* is a
5679-
sequence of (*x*, *y*) vertices for a custom scatter
5680-
symbol. Alternatively, use the kwarg combination
5681-
*marker* = *None*, *verts* = *verts*.
5655+
%(MarkerTable)s
56825656
56835657
Any or all of *x*, *y*, *s*, and *c* may be masked arrays, in
56845658
which case all masks will be combined and only unmasked points

lib/matplotlib/lines.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,19 +736,20 @@ def set_linestyle(self, linestyle):
736736
linestyle = 'None'
737737
self._linestyle = linestyle
738738

739+
@docstring.dedent_interpd
739740
def set_marker(self, marker):
740741
"""
741742
Set the line marker
742743
743-
%s
744+
%(MarkerTable)s
744745
745-
%s
746-
""" % (MarkerStyle.style_table, MarkerStyle.accepts)
746+
%(MarkerAccepts)s
747+
"""
747748
try:
748749
self._marker.set_marker(marker)
749750
except ValueError as e:
750751
verbose.report(str(e))
751-
752+
752753
def set_markeredgecolor(self, ec):
753754
"""
754755
Set the marker edge color

lib/matplotlib/markers.py

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
`~matplotlib.axes.Axes.scatter`.
55
"""
66

7+
import textwrap
8+
79
import numpy as np
810

911
from cbook import is_math_text, is_string_like, is_numlike, iterable
12+
import docstring
1013
from matplotlib import rcParams
1114
from path import Path
1215
from transforms import IdentityTransform, Affine2D
@@ -17,20 +20,43 @@
1720

1821
class MarkerStyle:
1922
style_table = """
20-
======================== =====================================================
21-
marker description
22-
======================== =====================================================
23+
============================== ===============================================
24+
marker description
25+
============================== ===============================================
2326
%s
24-
``'$...$'`` render the string using mathtext
25-
(numsides, style, angle) see below
26-
verts where verts is a list of (x, y) pairs in range (0, 1)
27-
======================== =====================================================
28-
29-
TODO: Describe tuple form
27+
``'$...$'`` render the string using mathtext
28+
*verts* a list of (x, y) pairs in range (0, 1)
29+
(*numsides*, *style*, *angle*) see below
30+
============================== ===============================================
31+
32+
The marker can also be a tuple (*numsides*, *style*, *angle*), which
33+
will create a custom, regular symbol.
34+
35+
*numsides*:
36+
the number of sides
37+
38+
*style*:
39+
the style of the regular symbol:
40+
41+
===== =============================================
42+
Value Description
43+
===== =============================================
44+
0 a regular polygon
45+
1 a star-like symbol
46+
2 an asterisk
47+
3 a circle (*numsides* and *angle* is ignored)
48+
===== =============================================
49+
50+
*angle*:
51+
the angle of rotation of the symbol
52+
53+
For backward compatibility, the form (*verts*, 0) is also accepted,
54+
but it is equivalent to just *verts* for giving a raw set of vertices
55+
that define the shape.
3056
"""
3157

3258
# TODO: Automatically generate this
33-
accepts = """ACCEPTS: [ %s | ``'$...$'`` | tuple ]"""
59+
accepts = """ACCEPTS: [ %s | ``'$...$'`` | *tuple* | *Nx2 array* ]"""
3460

3561
markers = {
3662
'.' : 'point',
@@ -603,11 +629,14 @@ def _set_x(self):
603629
self._path = self._x_path
604630

605631
_styles = [(repr(x), y) for x, y in MarkerStyle.markers.items()]
606-
_styles.sort()
632+
_styles.sort(lambda x, y: cmp(x[1], y[1]))
607633
MarkerStyle.style_table = (
608634
MarkerStyle.style_table %
609-
'\n'.join(['``%7s`` %33s' % (x, y) for (x, y) in _styles]))
635+
'\n'.join(['%-30s %-33s' % ('``%s``' % x, y) for (x, y) in _styles]))
610636

611-
MarkerStyle.accepts = (
637+
MarkerStyle.accepts = textwrap.fill(
612638
MarkerStyle.accepts %
613639
' | '.join(['``%s``' % x for (x, y) in _styles]))
640+
641+
docstring.interpd.update(MarkerTable=MarkerStyle.style_table)
642+
docstring.interpd.update(MarkerAccepts=MarkerStyle.accepts)

0 commit comments

Comments
 (0)