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

Skip to content

Commit 6e49fd7

Browse files
authored
Merge pull request #20573 from timhoffm/marker-path-reference
Move the marker path example into the marker reference
2 parents a4648e0 + e9fde87 commit 6e49fd7

File tree

4 files changed

+36
-39
lines changed

4 files changed

+36
-39
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ per-file-ignores =
110110
tutorials/toolkits/axisartist.py: E501
111111

112112
examples/animation/frame_grabbing_sgskip.py: E402
113+
examples/lines_bars_and_markers/marker_reference.py: E402
113114
examples/images_contours_and_fields/tricontour_demo.py: E201
114115
examples/images_contours_and_fields/tripcolor_demo.py: E201
115116
examples/images_contours_and_fields/triplot_demo.py: E201

examples/lines_bars_and_markers/marker_reference.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
- `Unfilled markers`_
1010
- `Filled markers`_
1111
- `Markers created from TeX symbols`_
12-
- Custom markers can be created from paths. See
13-
:doc:`/gallery/shapes_and_collections/marker_path`.
12+
- `Markers created from Paths`_
1413
1514
For a list of all markers see also the `matplotlib.markers` documentation.
1615
1716
For example usages see
1817
:doc:`/gallery/lines_bars_and_markers/scatter_star_poly`.
18+
19+
.. redirect-from:: /gallery/shapes_and_collections/marker_path
1920
"""
2021

2122
import matplotlib.pyplot as plt
@@ -126,3 +127,35 @@ def split_list(a_list):
126127
format_axes(ax)
127128

128129
plt.show()
130+
131+
132+
###############################################################################
133+
# Markers created from Paths
134+
# ==========================
135+
#
136+
# Any `~.path.Path` can be used as a marker. The following example shows two
137+
# simple paths *star* and *circle*, and a more elaborate path of a circle with
138+
# a cut-out star.
139+
140+
import matplotlib.path as mpath
141+
import numpy as np
142+
143+
star = mpath.Path.unit_regular_star(6)
144+
circle = mpath.Path.unit_circle()
145+
# concatenate the circle with an internal cutout of the star
146+
cut_star = mpath.Path(
147+
vertices=np.concatenate([circle.vertices, star.vertices[::-1, ...]]),
148+
codes=np.concatenate([circle.codes, star.codes]))
149+
150+
fig, ax = plt.subplots()
151+
fig.suptitle('Path markers', fontsize=14)
152+
fig.subplots_adjust(left=0.4)
153+
154+
markers = {'star': star, 'circle': circle, 'cut_star': cut_star}
155+
156+
for y, (name, marker) in enumerate(markers.items()):
157+
ax.text(-0.5, y, name, **text_style)
158+
ax.plot([y] * 3, marker=marker, **marker_style)
159+
format_axes(ax)
160+
161+
plt.show()

examples/shapes_and_collections/marker_path.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

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/shapes_and_collections/marker_path`
8786
* :doc:`/gallery/lines_bars_and_markers/scatter_star_poly`
8887
8988

0 commit comments

Comments
 (0)