8000 Merge pull request #13762 from anntzer/markerref · matplotlib/matplotlib@b741c00 · GitHub
[go: up one dir, main page]

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 b741c00

Browse files
authored
Merge pull request #13762 from anntzer/markerref
Cleanup marker_reference example.
2 parents fc6ea85 + 890ef82 commit b741c00

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

examples/lines_bars_and_markers/marker_reference.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ def format_axes(ax):
2828
ax.invert_yaxis()
2929

3030

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 r"'\${}\$'".format(tx)
38-
39-
4031
def split_list(a_list):
4132
i_half = len(a_list) // 2
4233
return (a_list[:i_half], a_list[i_half:])
@@ -46,7 +37,6 @@ def split_list(a_list):
4637
# Filled and unfilled-marker types
4738
# ================================
4839
#
49-
#
5040
# Plot all un-filled markers
5141

5242
fig, axes = plt.subplots(ncols=2)
@@ -58,9 +48,9 @@ def split_list(a_list):
5848

5949
for ax, markers in zip(axes, split_list(unfilled_markers)):
6050
for y, marker in enumerate(markers):
61-
ax.text(-0.5, y, nice_repr(marker), **text_style)
51+
ax.text(-0.5, y, repr(marker), **text_style)
6252
ax.plot(y * points, marker=marker, **marker_style)
63-
format_axes(ax)
53+
format_axes(ax)
6454

6555
plt.show()
6656

@@ -71,9 +61,9 @@ def split_list(a_list):
7161
fig, axes = plt.subplots(ncols=2)
7262
for ax, markers in zip(axes, split_list(Line2D.filled_markers)):
7363
for y, marker in enumerate(markers):
74-
ax.text(-0.5, y, nice_repr(marker), **text_style)
64+
ax.text(-0.5, y, repr(marker), **text_style)
7565
ax.plot(y * points, marker=marker, **marker_style)
76-
format_axes(ax)
66+
format_axes(ax)
7767
fig.suptitle('filled markers', fontsize=14)
7868

7969
plt.show()
@@ -83,7 +73,6 @@ def split_list(a_list):
8373
# Custom Markers with MathText
8474
# ============================
8575
#
86-
#
8776
# Use :doc:`MathText </tutorials/text/mathtext>`, to use custom marker symbols,
8877
# like e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer
8978
# to the `STIX font table <http://www.stixfonts.org/allGlyphs.html>`_.
@@ -99,8 +88,10 @@ def split_list(a_list):
9988

10089

10190
for y, marker in enumerate(markers):
102-
ax.text(-0.5, y, math_repr(marker), **text_style)
91+
# Escape dollars so that the text is written "as is", not as mathtext.
92+
ax.text(-0.5, y, repr(marker).replace("$", r"\$"), **text_style)
10393
ax.plot(y * points, marker=marker, **marker_style)
10494
format_axes(ax)
95+
fig.suptitle('mathtext markers', fontsize=14)
10596

10697
plt.show()

0 commit comments

Comments
 (0)
0