8000 MEP10 - documentation improvements on the markers module · ivanov/matplotlib@0210aa5 · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit 0210aa5

Browse files
committed
MEP10 - documentation improvements on the markers module
1 parent f2fcd0c commit 0210aa5

File tree

3 files changed

+97
-39
lines changed

3 files changed

+97
-39
lines changed

doc/api/markers_api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*******
2+
Markers*
3+
******
4+
5+
6+
:mod:`matplotlib.markers`
7+
========================
8+
9+
.. automodule:: matplotlib.markers
10+
:members:
11+
:undoc-members:
12+
:show-inheritance:

lib/matplotlib/lines.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,13 @@ def set_marker(self, marker):
816816
"""
817817
Set the line marker
818818
819-
%(MarkerTable)s
819+
Parameters
820+
-----------
821+
822+
marker: marker style
823+
See `~matplotlib.markers` for full description of possible
824+
argument
820825
821-
%(MarkerAccepts)s
822826
"""
823827
self._marker.set_marker(marker)
824828

lib/matplotlib/markers.py

Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,60 @@
22
This module contains functions to handle markers. Used by both the
33
marker functionality of `~matplotlib.axes.Axes.plot` and
44
`~matplotlib.axes.Axes.scatter`.
5-
"""
6-
7-
import textwrap
85
9-
import numpy as np
10-
11-
from cbook import is_math_text, is_string_like, is_numlike, iterable
12-
import docstring
13-
from matplotlib import rcParams
14-
from path import Path
15-
from transforms import IdentityTransform, Affine2D
6+
All possible markers are defined here:
167
17-
# special-purpose marker identifiers:
18-
(TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN,
19-
CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN) = range(8)
20-
21-
22-
class MarkerStyle(object):
23-
style_table = """
248
============================== ===============================================
259
marker description
2610
============================== ===============================================
27-
%s
11+
"." point
12+
"," pixel
13+
"o" circle
14+
"v" triangle_down
15+
"^" triangle_up
16+
"<" triangle_left
17+
">" triangle_right
18+
"1" tri_down
19+
"2" tri_up
20+
"3" tri_left
21+
"4" tri_right
22+
"8" octagon
23+
"s" square
24+
"p" pentagon
25+
"*" star
26+
"h" hexagon1
27+
"H" hexagon2
28+
"+" plus
29+
"x" x
30+
"D" diamond
31+
"d" thin_diamond
32+
"|" vline
33+
"_" hline
34+
TICKLEFT tickleft
35+
TICKRIGHT tickright
36+
TICKUP tickup
37+
TICKDOWN tickdown
38+
CARETLEFT caretleft
39+
CARETRIGHT caretright
40+
CARETUP caretup
41+
CARETDOWN caretdown
42+
"None" nothing
43+
None nothing
44+
" " nothing
45+
"" nothing
2846
``'$...$'`` render the string using mathtext.
29-
*verts* a list of (x, y) pairs used for Path vertices.
30-
path a :class:`~matplotlib.path.Path` instance.
31-
(*numsides*, *style*, *angle*) see below
47+
`verts` a list of (x, y) pairs used for Path vertices.
48+
path a `~matplotlib.path.Path` instance.
49+
(`numsides`, `style`, `angle`) see below
3250
============================== ===============================================
3351
34-
The marker can also be a tuple (*numsides*, *style*, *angle*), which
52+
The marker can also be a tuple (`numsides`, `style`, `angle`), which
3553
will create a custom, regular symbol.
3654
37-
*numsides*:
55+
`numsides`:
3856
the number of sides
3957
40-
*style*:
58+
`style`:
4159
the style of the regular symbol:
4260
4361
===== =============================================
@@ -46,19 +64,41 @@ class MarkerStyle(object):
4664
0 a regular polygon
4765
1 a star-like symbol
4866
2 an asterisk
49-
3 a circle (*numsides* and *angle* is ignored)
67+
3 a circle (`numsides` and `angle` is ignored)
5068
===== =============================================
5169
52-
*angle*:
70+
`angle`:
5371
the angle of rotation of the symbol, in degrees
5472
55-
For backward compatibility, the form (*verts*, 0) is also accepted,
56-
but it is equivalent to just *verts* for giving a raw set of vertices
73+
For backward compatibility, the form (`verts`, 0) is also accepted,
74+
but it is equivalent to just `verts` for giving a raw set of vertices
5775
that define the shape.
5876
"""
5977

78+
import numpy as np
79+
80+
from cbook import is_math_text, is_string_like, is_numlike, iterable
81+
import docstring
82+
from matplotlib import rcParams
83+
from path import Path
84+
from transforms import IdentityTransform, Affine2D
85+
86+
# special-purpose marker identifiers:
87+
(TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN,
88+
CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN) = range(8)
89+
90+
91+
class MarkerStyle(object):
92+
"""
93+
Markers object
94+
95+
"""
96+
# FIXME: get rid of this
97+
style_table = """"""
98+
6099
# TODO: Automatically generate this
61-
accepts = """ACCEPTS: [ %s | ``'$...$'`` | *tuple* | *Nx2 array* ]"""
100+
# Get rid of this
101+
accepts = """"""
62102

63103
markers = {
64104
'.': 'point',
@@ -110,6 +150,16 @@ class MarkerStyle(object):
110150
_point_size_reduction = 0.5
111151

112152
def __init__(self, marker=None, fillstyle='full'):
153+
"""
154+
155+
Parameters
156+
----------
157+
marker : string or array_like, optional, default: None
158+
See the descriptions of possible markers in the module docstring.
159+
160+
fillstyle : string, optional, default: 'full'
161+
'full', 'left", 'right', 'bottom', 'top', 'none'
162+
"""
113163
self._fillstyle = fillstyle
114164
self.set_marker(marker)
115165
self.set_fillstyle(fillstyle)
@@ -720,13 +770,5 @@ def _set_x(self):
720770

721771
_styles = [(repr(x), y) for x, y in MarkerStyle.markers.items()]
722772
_styles.sort(key=lambda x: x[1])
723-
MarkerStyle.style_table = (
724-
MarkerStyle.style_table %
725-
'\n'.join(['%-30s %-33s' % ('``%s``' % x, y) for (x, y) in _styles]))
726-
727-
MarkerStyle.accepts = textwrap.fill(
728-
MarkerStyle.accepts %
729-
' | '.join(['``%s``' % x for (x, y) in _styles]))
730-
731773
docstring.interpd.update(MarkerTable=MarkerStyle.style_table)
732774
docstring.interpd.update(MarkerAccepts=MarkerStyle.accepts)

0 commit comments

Comments
 (0)
0