Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bfa8d61

Browse filesBrowse files
authored
Merge pull request #11437 from ImportanceOfBeingErnest/doc_markersupdate
Doc markersupdate
2 parents 9714469 + 354fa7d commit bfa8d61
Copy full SHA for bfa8d61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

41 files changed

+205
-87
lines changed

‎doc/_static/markers/m00.png

Copy file name to clipboard
376 Bytes

‎doc/_static/markers/m01.png

Copy file name to clipboard
226 Bytes

‎doc/_static/markers/m02.png

Copy file name to clipboard
504 Bytes

‎doc/_static/markers/m03.png

Copy file name to clipboard
411 Bytes

‎doc/_static/markers/m04.png

Copy file name to clipboard
399 Bytes

‎doc/_static/markers/m05.png

Copy file name to clipboard
422 Bytes

‎doc/_static/markers/m06.png

Copy file name to clipboard
400 Bytes

‎doc/_static/markers/m07.png

Copy file name to clipboard
394 Bytes

‎doc/_static/markers/m08.png

Copy file name to clipboard
400 Bytes

‎doc/_static/markers/m09.png

Copy file name to clipboard
395 Bytes

‎doc/_static/markers/m10.png

Copy file name to clipboard
407 Bytes

‎doc/_static/markers/m11.png

Copy file name to clipboard
356 Bytes

‎doc/_static/markers/m12.png

Copy file name to clipboard
314 Bytes

‎doc/_static/markers/m13.png

Copy file name to clipboard
492 Bytes

‎doc/_static/markers/m14.png

Copy file name to clipboard
500 Bytes

‎doc/_static/markers/m15.png

Copy file name to clipboard
448 Bytes

‎doc/_static/markers/m16.png

Copy file name to clipboard
475 Bytes

‎doc/_static/markers/m17.png

Copy file name to clipboard
349 Bytes

‎doc/_static/markers/m18.png

Copy file name to clipboard
361 Bytes

‎doc/_static/markers/m19.png

Copy file name to clipboard
366 Bytes

‎doc/_static/markers/m20.png

Copy file name to clipboard
585 Bytes

‎doc/_static/markers/m21.png

Copy file name to clipboard
264 Bytes

‎doc/_static/markers/m22.png

Copy file name to clipboard
271 Bytes

‎doc/_static/markers/m23.png

Copy file name to clipboard
415 Bytes

‎doc/_static/markers/m24.png

Copy file name to clipboard
431 Bytes

‎doc/_static/markers/m25.png

Copy file name to clipboard
270 Bytes

‎doc/_static/markers/m26.png

Copy file name to clipboard
252 Bytes

‎doc/_static/markers/m27.png

Copy file name to clipboard
254 Bytes

‎doc/_static/markers/m28.png

Copy file name to clipboard
248 Bytes

‎doc/_static/markers/m29.png

Copy file name to clipboard
417 Bytes

‎doc/_static/markers/m30.png

Copy file name to clipboard
413 Bytes

‎doc/_static/markers/m31.png

Copy file name to clipboard
416 Bytes

‎doc/_static/markers/m32.png

Copy file name to clipboard
425 Bytes

‎doc/_static/markers/m33.png

Copy file name to clipboard
420 Bytes

‎doc/_static/markers/m34.png

Copy file name to clipboard
411 Bytes

‎doc/_static/markers/m35.png

Copy file name to clipboard
418 Bytes

‎doc/_static/markers/m36.png

Copy file name to clipboard
423 Bytes

‎doc/_static/markers/m37.png

Copy file name to clipboard
483 Bytes

‎examples/lines_bars_and_markers/marker_fillstyle_reference.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/marker_fillstyle_reference.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
=====================
55
66
Reference for marker fill-styles included with Matplotlib.
7+
8+
Also refer to the
9+
:doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`
10+
and :doc:`/gallery/shapes_and_collections/marker_path` examples.
711
"""
812
import numpy as np
913
import matplotlib.pyplot as plt
+59-12Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
"""
2-
================================
3-
Filled and unfilled-marker types
4-
================================
2+
================
3+
Marker Reference
4+
================
55
6-
Reference for filled- and unfilled-marker types included with Matplotlib.
6+
Reference for filled-, unfilled- and custom marker types with Matplotlib.
7+
8+
For a list of all markers see the `matplotlib.markers` documentation. Also
9+
refer to the :doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`
10+
and :doc:`/gallery/shapes_and_collections/marker_path` examples.
711
"""
812

913
import numpy as np
@@ -14,36 +18,52 @@
1418
points = np.ones(3) # Draw 3 points for each line
1519
text_style = dict(horizontalalignment='right', verticalalignment='center',
1620
fontsize=12, fontdict={'family': 'monospace'})
17-
marker_style = dict(linestyle=':', color='cornflowerblue', markersize=10)
21+
marker_style = dict(linestyle=':', color='0.8', markersize=10,
22+
mfc="C0", mec="C0")
1823

1924

2025
def format_axes(ax):
2126
ax.margins(0.2)
2227
ax.set_axis_off()
28+
ax.invert_yaxis()
29+
30+
31+
def nice_repr(text):
32+
return repr(text).lstrip('u')
33+
34+
35+
def math_repr(text):
36+
tx = repr(text).lstrip('u').strip("'").strip("$")
37+
return "'\${}\$'".format(tx)
2338

2439

2540
def split_list(a_list):
2641
i_half = len(a_list) // 2
2742
return (a_list[:i_half], a_list[i_half:])
2843

44+
2945
###############################################################################
46+
# Filled and unfilled-marker types
47+
# ================================
48+
#
49+
#
3050
# Plot all un-filled markers
3151

3252
fig, axes = plt.subplots(ncols=2)
53+
fig.suptitle('un-filled markers', fontsize=14)
3354

3455
# Filter out filled markers and marker settings that do nothing.
3556
unfilled_markers = [m for m, func in Line2D.markers.items()
3657
if func != 'nothing' and m not in Line2D.filled_markers]
37-
# Reverse-sort for pretty. We use our own sort key which is essentially
38-
# a python3 compatible reimplementation of python2 sort.
39-
unfilled_markers = sorted(unfilled_markers,
40-
key=lambda x: (str(type(x)), str(x)))[::-1]
58+
4159
for ax, markers in zip(axes, split_list(unfilled_markers)):
4260
for y, marker in enumerate(markers):
43-
ax.text(-0.5, y, repr(marker), **text_style)
61+
ax.text(-0.5, y, nice_repr(marker), **text_style)
4462
ax.plot(y * points, marker=marker, **marker_style)
4563
format_axes(ax)
46-
fig.suptitle('un-filled markers', fontsize=14)
64+
65+
plt.show()
66+
4767

4868

4969
###############################################################################
@@ -52,9 +72,36 @@ def split_list(a_list):
5272
fig, axes = plt.subplots(ncols=2)
5373
for ax, markers in zip(axes, split_list(Line2D.filled_markers)):
5474
for y, marker in enumerate(markers):
55-
ax.text(-0.5, y, repr(marker), **text_style)
75+
ax.text(-0.5, y, nice_repr(marker), **text_style)
5676
ax.plot(y * points, marker=marker, **marker_style)
5777
format_axes(ax)
5878
fig.suptitle('filled markers', fontsize=14)
5979

6080
plt.show()
81+
82+
83+
###############################################################################
84+
# Custom Markers with MathText
85+
# ============================
86+
#
87+
#
88+
# Use :doc:`MathText </tutorials/text/mathtext>`, to use custom marker symbols,
89+
# like e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer to the
90+
# `STIX font table <http://www.stixfonts.org/allGlyphs.html>`_.
91+
# Also see the :doc:`/gallery/text_labels_and_annotations/stix_fonts_demo`.
92+
93+
94+
fig, ax = plt.subplots()
95+
fig.subplots_adjust(left=0.4)
96+
97+
marker_style.update(mec="None", markersize=15)
98+
markers = ["$1$", r"$\frac{1}{2}$", "$f$", "$\u266B$",
99+
r"$\mathcircled{m}$"]
100+
101+
102+
for y, marker in enumerate(markers):
103+
ax.text(-0.5, y, math_repr(marker), **text_style)
104+
ax.plot(y * points, marker=marker, **marker_style)
105+
format_axes(ax)
106+
107+
plt.show()

‎lib/matplotlib/markers.py

Copy file name to clipboardExpand all lines: lib/matplotlib/markers.py
+142-75Lines changed: 142 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,82 +5,149 @@
55
66
All possible markers are defined here:
77
8-
============================== ===============================================
9-
marker description
10-
============================== ===============================================
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-
`"P"` plus (filled)
26-
`"*"` star
27-
`"h"` hexagon1
28-
`"H"` hexagon2
29-
`"+"` plus
30-
`"x"` x
31-
`"X"` x (filled)
32-
`"D"` diamond
33-
`"d"` thin_diamond
34-
`"|"` vline
35-
`"_"` hline
36-
TICKLEFT tickleft
37-
TICKRIGHT tickright
38-
TICKUP tickup
39-
TICKDOWN tickdown
40-
CARETLEFT caretleft (centered at tip)
41-
CARETRIGHT caretright (centered at tip)
42-
CARETUP caretup (centered at tip)
43-
CARETDOWN caretdown (centered at tip)
44-
CARETLEFTBASE caretleft (centered at base)
45-
CARETRIGHTBASE caretright (centered at base)
46-
CARETUPBASE caretup (centered at base)
47-
`"None"`, `" "` or `""` nothing
48-
``'$...$'`` render the string using mathtext.
49-
`verts` a list of (x, y) pairs used for Path vertices.
50-
The center of the marker is located at (0,0) and
51-
the size is normalized.
52-
path a `~matplotlib.path.Path` instance.
53-
(`numsides`, `style`, `angle`) The marker can also be a tuple (`numsides`,
54-
`style`, `angle`), which will create a custom,
55-
regular symbol.
56-
57-
`numsides`:
58-
the number of sides
59-
60-
`style`:
61-
the style of the regular symbol:
62-
63-
0
64-
a regular polygon
65-
1
66-
a star-like symbol
67-
2
68-
an asterisk
69-
3
70-
a circle (`numsides` and `angle` is
71-
ignored); deprecated.
72-
73-
`angle`:
74-
the angle of rotation of the symbol
75-
============================== ===============================================
76-
77-
For backward compatibility, the form (`verts`, 0) is also accepted, but it is
78-
deprecated and equivalent to just `verts` for giving a raw set of vertices that
79-
define the shape.
80-
81-
`None` is the default which means 'nothing', however this table is
8+
============================== ====== =========================================
9+
marker symbol description
10+
============================== ====== =========================================
11+
``"."`` |m00| point
12+
``","`` |m01| pixel
13+
``"o"`` |m02| circle
14+
``"v"`` |m03| triangle_down
15+
``"^"`` |m04| triangle_up
16+
``"<"`` |m05| triangle_left
17+
``">"`` |m06| triangle_right
18+
``"1"`` |m07| tri_down
19+
``"2"`` |m08| tri_up
20+
``"3"`` |m09| tri_left
21+
``"4"`` |m10| tri_right
22+
``"8"`` |m11| octagon
23+
``"s"`` |m12| square
24+
``"p"`` |m13| pentagon
25+
``"P"`` |m23| plus (filled)
26+
``"*"`` |m14| star
27+
``"h"`` |m15| hexagon1
28+
``"H"`` |m16| hexagon2
29+
``"+"`` |m17| plus
30+
``"x"`` |m18| x
31+
``"X"`` |m21| x (filled)
32+
``"D"`` |m19| diamond
33+
``"d"`` |m20| thin_diamond
34+
``"|"`` |m21| vline
35+
``"_"`` |m22| hline
36+
``0`` (``TICKLEFT``) |m25| tickleft
37+
``1`` (``TICKRIGHT``) |m26| tickright
38+
``2`` (``TICKUP``) |m27| tickup
39+
``3`` (``TICKDOWN``) |m28| tickdown
40+
``4`` (``CARETLEFT``) |m29| caretleft
41+
``5`` (``CARETRIGHT``) |m30| caretright
42+
``6`` (``CARETUP``) |m31| caretup
43+
``7`` (``CARETDOWN``) |m32| caretdown
44+
``8`` (``CARETLEFTBASE``) |m33| caretleft (centered at base)
45+
``9`` (``CARETRIGHTBASE``) |m34| caretright (centered at base)
46+
``10`` (``CARETUPBASE``) |m35| caretup (centered at base)
47+
``11`` (``CARETDOWNBASE``) |m36| caretdown (centered at base)
48+
``"None"``, ``" "`` or ``""`` nothing
49+
``'$...$'`` |m37| Render the string using mathtext.
50+
E.g ``"$f$"`` for marker showing the
51+
letter ``f``.
52+
``verts`` A list of (x, y) pairs used for Path
53+
vertices. The center of the marker is
54+
located at (0,0) and the size is
55+
normalized, such that the created path
56+
is encapsulated inside the unit cell.
57+
path A `~matplotlib.path.Path` instance.
58+
``(numsides, style, angle)`` The marker can also be a tuple
59+
``(numsides, style, angle)``, which
60+
will create a custom, regular symbol.
61+
62+
``numsides``:
63+
the number of sides
64+
65+
``style``:
66+
the style of the regular symbol:
67+
68+
+---+-----------------------------+
69+
| 0 | a regular polygon |
70+
+---+-----------------------------+
71+
| 1 | a star-like symbol |
72+
+---+-----------------------------+
73+
| 2 | an asterisk |
74+
+---+-----------------------------+
75+
| 3 | a circle (``numsides`` and |
76+
| | ``angle`` is ignored); |
77+
| | deprecated. |
78+
+---+-----------------------------+
79+
80+
``angle``:
81+
the angle of rotation of the symbol
82+
============================== ====== =========================================
83+
84+
For backward compatibility, the form ``(verts, 0)`` is also accepted, but it is
85+
deprecated and equivalent to just ``verts`` for giving a raw set of vertices
86+
that define the shape.
87+
88+
``None`` is the default which means 'nothing', however this table is
8289
referred to from other docs for the valid inputs from marker inputs and in
83-
those cases `None` still means 'default'.
90+
those cases ``None`` still means 'default'.
91+
92+
Note that special symbols can be defined via the
93+
:doc:`STIX math font </tutorials/text/mathtext>`,
94+
e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer to the
95+
`STIX font table <http://www.stixfonts.org/allGlyphs.html>`_.
96+
Also see the :doc:`/gallery/text_labels_and_annotations/stix_fonts_demo`.
97+
98+
Integer numbers from ``0`` to ``11`` create lines and triangles. Those are
99+
equally accessible via capitalized variables, like ``CARETDOWNBASE``.
100+
Hence the following are equivalent::
101+
102+
plt.plot([1,2,3], marker=11)
103+
plt.plot([1,2,3], marker=matplotlib.markers.CARETDOWNBASE)
104+
105+
106+
Examples showing the use of markers:
107+
108+
* :doc:`/gallery/lines_bars_and_markers/marker_reference`
109+
* :doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`
110+
* :doc:`/gallery/shapes_and_collections/marker_path`
111+
112+
113+
.. |m00| image:: /_static/markers/m00.png
114+
.. |m01| image:: /_static/markers/m01.png
115+
.. |m02| image:: /_static/markers/m02.png
116+
.. |m03| image:: /_static/markers/m03.png
117+
.. |m04| image:: /_static/markers/m04.png
118+
.. |m05| image:: /_static/markers/m05.png
119+
.. |m06| image:: /_static/markers/m06.png
120+
.. |m07| image:: /_static/markers/m07.png
121+
.. |m08| image:: /_static/markers/m08.png
122+
.. |m09| image:: /_static/markers/m09.png
123+
.. |m10| image:: /_static/markers/m10.png
124+
.. |m11| image:: /_static/markers/m11.png
125+
.. |m12| image:: /_static/markers/m12.png
126+
.. |m13| image:: /_static/markers/m13.png
127+
.. |m14| image:: /_static/markers/m14.png
128+
.. |m15| image:: /_static/markers/m15.png
129+
.. |m16| image:: /_static/markers/m16.png
130+
.. |m17| image:: /_static/markers/m17.png
131+
.. |m18| image:: /_static/markers/m18.png
132+
.. |m19| image:: /_static/markers/m19.png
133+
.. |m20| image:: /_static/markers/m20.png
134+
.. |m21| image:: /_static/markers/m21.png
135+
.. |m22| image:: /_static/markers/m22.png
136+
.. |m23| image:: /_static/markers/m23.png
137+
.. |m24| image:: /_static/markers/m24.png
138+
.. |m25| image:: /_static/markers/m25.png
139+
.. |m26| image:: /_static/markers/m26.png
140+
.. |m27| image:: /_static/markers/m27.png
141+
.. |m28| image:: /_static/markers/m28.png
142+
.. |m29| image:: /_static/markers/m29.png
143+
.. |m30| image:: /_static/markers/m30.png
144+
.. |m31| image:: /_static/markers/m31.png
145+
.. |m32| image:: /_static/markers/m32.png
146+
.. |m33| image:: /_static/markers/m33.png
147+
.. |m34| image:: /_static/markers/m34.png
148+
.. |m35| image:: /_static/markers/m35.png
149+
.. |m36| image:: /_static/markers/m36.png
150+
.. |m37| image:: /_static/markers/m37.png
84151
"""
85152

86153
from collections import Sized

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.