8000 Join marker reference and marker fillstyle reference · matplotlib/matplotlib@6f4efa9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f4efa9

Browse files
committed
Join marker reference and marker fillstyle reference
1 parent e70c9d2 commit 6f4efa9

File tree

4 files changed

+54
-59
lines changed

4 files changed

+54
-59
lines changed

examples/lines_bars_and_markers/marker_fillstyle_reference.py

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
"""
22
================
3-
Marker Reference
3+
Marker reference
44
================
55
6-
Reference for filled-, unfilled- and custom marker types with Matplotlib.
6+
Matplotlib supports multiple categories of markers which are selected using
7+
the ``marker`` parameter of plot commands:
78
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.
9+
- `Unfilled markers`_
10+
- `Filled markers`_
11+
- `Markers created from TeX symbols`_
12+
- Custom markers can be created from paths. See
13+
:doc:`/gallery/shapes_and_collections/marker_path`.
14+
15+
For a list of all markers see also the `matplotlib.markers` documentation.
1116
"""
1217

1318
import numpy as np
1419
import matplotlib.pyplot as plt
1520
from matplotlib.lines import Line2D
1621

1722

18-
points = np.ones(3) # Draw 3 points for each line
1923
text_style = dict(horizontalalignment='right', verticalalignment='center',
20-
fontsize=12, fontdict={'family': 'monospace'})
24+
fontsize=12, fontfamily='monospace')
2125
marker_style = dict(linestyle=':', color='0.8', markersize=10,
22-
mfc="C0", mec="C0")
26+
mfc="tab:blue", mec="tab:blue")
2327

2428

2529
def format_axes(ax):
@@ -30,17 +34,16 @@ def format_axes(ax):
3034

3135
def split_list(a_list):
3236
i_half = len(a_list) // 2
33-
return (a_list[:i_half], a_list[i_half:])
37+
return a_list[:i_half], a_list[i_half:]
3438

3539

3640
###############################################################################
37-
# Filled and unfilled-marker types
38-
# ================================
39-
#
40-
# Plot all un-filled markers
41+
# Unfilled markers
42+
# ================
43+
# Unfilled markers are single-colored.
4144

4245
fig, axs = plt.subplots(ncols=2)
43-
fig.suptitle('un-filled markers', fontsize=14)
46+
fig.suptitle('Un-filled markers', fontsize=14)
4447

4548
# Filter out filled markers and marker settings that do nothing.
4649
unfilled_markers = [m for m, func in Line2D.markers.items()
@@ -49,29 +52,57 @@ def split_list(a_list):
4952
for ax, markers in zip(axs, split_list(unfilled_markers)):
5053
for y, marker in enumerate(markers):
5154
ax.text(-0.5, y, repr(marker), **text_style)
52-
ax.plot(y * points, marker=marker, **marker_style)
55+
ax.plot([y] * 3, marker=marker, **marker_style)
5356
format_axes(ax)
5457

5558
plt.show()
5659

5760

5861
###############################################################################
59-
# Plot all filled markers.
62+
# Filled markers
63+
# ==============
6064

6165
fig, axs = plt.subplots(ncols=2)
66+
fig.suptitle('Filled markers', fontsize=14)
6267
for ax, markers in zip(axs, split_list(Line2D.filled_markers)):
6368
for y, marker in enumerate(markers):
6469
ax.text(-0.5, y, repr(marker), **text_style)
65-
ax.plot(y * points, marker=marker, **marker_style)
70+
ax.plot([y] * 3, marker=marker, **marker_style)
6671
format_axes(ax)
67-
fig.suptitle('filled markers', fontsize=14)
72+
73+
plt.show()
74+
75+
###############################################################################
76+
# .. _marker_fill_styles:
77+
#
78+
# Marker fill styles
79+
# ------------------
80+
# The edge color and fill color of filled markers can be specified separately.
81+
# Additionally, the ``fillstyle`` can be configured to be unfilled, fully
82+
# filled, or half-filled in various directions. The half-filled styles use
83+
# ``markerfacecoloralt`` as secondary fill color.
84+
85+
fig, ax = plt.subplots()
86+
fig.suptitle('Marker fillstyle', fontsize=14)
87+
fig.subplots_adjust(left=0.4)
88+
89+
filled_marker_style = dict(marker='o', linestyle=':', markersize=15,
90+
color='darkgrey',
91+
markerfacecolor='tab:blue',
92+
markerfacecoloralt='lightsteelblue',
93+
markeredgecolor='brown')
94+
95+
for y, fill_style in enumerate(Line2D.fillStyles):
96+
ax.text(-0.5, y, repr(fill_style), **text_style)
97+
ax.plot([y] * 3, fillstyle=fill_style, **filled_marker_style)
98+
format_axes(ax)
6899

69100
plt.show()
70101

71102

72103
###############################################################################
73-
# Custom Markers with MathText
74-
# ============================
104+
# Markers created from TeX symbols
105+
# ================================
75106
#
76107
# Use :doc:`MathText </tutorials/text/mathtext>`, to use custom marker symbols,
77108
# like e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer
@@ -80,17 +111,16 @@ def split_list(a_list):
80111

81112

82113
fig, ax = plt.subplots()
114+
fig.suptitle('Mathtext markers', fontsize=14)
83115
fig.subplots_adjust(left=0.4)
84116

85117
marker_style.update(mec="None", markersize=15)
86118
markers = ["$1$", r"$\frac{1}{2}$", "$f$", "$\u266B$", r"$\mathcal{A}$"]
87119

88-
89120
for y, marker in enumerate(markers):
90121
# Escape dollars so that the text is written "as is", not as mathtext.
91122
ax.text(-0.5, y, repr(marker).replace("$", r"\$"), **text_style)
92-
ax.plot(y * points, marker=marker, **marker_style)
123+
ax.plot([y] * 3, marker=marker, **marker_style)
93124
format_axes(ax)
94-
fig.suptitle('mathtext markers', fontsize=14)
95125

96126
plt.show()

lib/matplotlib/lines.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ def set_fillstyle(self, fs):
535535
half of the marker is filled with *markerfacecoloralt*.
536536
- 'none': No filling.
537537
538-
For examples see
539-
:doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`.
538+
For examples see :ref:`marker_fill_styles`.
540539
"""
541540
self._marker.set_fillstyle(fs)
542541
self.stale = True

lib/matplotlib/markers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
Examples showing the use of markers:
8484
8585
* :doc:`/gallery/lines_bars_and_markers/marker_reference`
86-
* :doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference`
8786
* :doc:`/gallery/shapes_and_collections/marker_path`
8887
8988

0 commit comments

Comments
 (0)
0