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

Skip to content

Backport PR #13762 on branch v3.1.x (Cleanup marker_reference example.) #13793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions examples/lines_bars_and_markers/marker_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ def format_axes(ax):
ax.invert_yaxis()


def nice_repr(text):
return repr(text).lstrip('u')


def math_repr(text):
tx = repr(text).lstrip('u').strip("'").strip("$")
return r"'\${}\$'".format(tx)


def split_list(a_list):
i_half = len(a_list) // 2
return (a_list[:i_half], a_list[i_half:])
Expand All @@ -46,7 +37,6 @@ def split_list(a_list):
# Filled and unfilled-marker types
# ================================
#
#
# Plot all un-filled markers

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

for ax, markers in zip(axes, split_list(unfilled_markers)):
for y, marker in enumerate(markers):
ax.text(-0.5, y, nice_repr(marker), **text_style)
ax.text(-0.5, y, repr(marker), **text_style)
ax.plot(y * points, marker=marker, **marker_style)
format_axes(ax)
format_axes(ax)

plt.show()

Expand All @@ -71,9 +61,9 @@ def split_list(a_list):
fig, axes = plt.subplots(ncols=2)
for ax, markers in zip(axes, split_list(Line2D.filled_markers)):
for y, marker in enumerate(markers):
ax.text(-0.5, y, nice_repr(marker), **text_style)
ax.text(-0.5, y, repr(marker), **text_style)
ax.plot(y * points, marker=marker, **marker_style)
format_axes(ax)
format_axes(ax)
fig.suptitle('filled markers', fontsize=14)

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


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

plt.show()