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

Skip to content

Commit 8ba284a

Browse files
committed
Join marker reference and marker fillstyle reference
1 parent e70c9d2 commit 8ba284a

File tree

4 files changed

+54
-60
lines changed

4 files changed

+54
-60
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 & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
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

13-
import numpy as np
1418
import matplotlib.pyplot as plt
1519
from matplotlib.lines import Line2D
1620

1721

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

2427

2528
def format_axes(ax):
@@ -30,17 +33,16 @@ def format_axes(ax):
3033

3134
def split_list(a_list):
3235
i_half = len(a_list) // 2
33-
return (a_list[:i_half], a_list[i_half:])
36+
return a_list[:i_half], a_list[i_half:]
3437

3538

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

4244
fig, axs = plt.subplots(ncols=2)
43-
fig.suptitle('un-filled markers', fontsize=14)
45+
fig.suptitle('Un-filled markers', fontsize=14)
4446

4547
# Filter out filled markers and marker settings that do nothing.
4648
unfilled_markers = [m for m, func in Line2D.markers.items()
@@ -49,29 +51,57 @@ def split_list(a_list):
4951
for ax, markers in zip(axs, split_list(unfilled_markers)):
5052
for y, marker in enumerate(markers):
5153
ax.text(-0.5, y, repr(marker), **text_style)
52-
ax.plot(y * points, marker=marker, **marker_style)
54+
ax.plot([y] * 3, marker=marker, **marker_style)
5355
format_axes(ax)
5456

5557
plt.show()
5658

5759

5860
###############################################################################
59-
# Plot all filled markers.
61+
# Filled markers
62+
# ==============
6063

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

6999
plt.show()
70100

71101

72102
###############################################################################
73-
# Custom Markers with MathText
74-
# ============================
103+
# Markers created from TeX symbols
104+
# ================================
75105
#
76106
# Use :doc:`MathText </tutorials/text/mathtext>`, to use custom marker symbols,
77107
# like e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer
@@ -80,17 +110,16 @@ def split_list(a_list):
80110

81111

82112
fig, ax = plt.subplots()
113+
fig.suptitle('Mathtext markers', fontsize=14)
83114
fig.subplots_adjust(left=0.4)
84115

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

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

96125
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