Skip to content

Support marker="none" to mean "no marker". #21055

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
merged 1 commit into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions doc/users/next_whats_new/marker_none.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``marker`` can now be set to the string "none"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... to mean *no-marker*, consistently with other APIs which support the
lowercase version. Using "none" is recommended over using "None", to avoid
confusion with the None object.
2 changes: 1 addition & 1 deletion lib/matplotlib/legend_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def create_artists(self, legend, orig_handle,
self.update_prop(legline, plotlines, legend)

legline.set_drawstyle('default')
legline.set_marker('None')
legline.set_marker('none')

self.update_prop(legline_marker, plotlines, legend)
legline_marker.set_linestyle('None')
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
``9`` (``CARETRIGHTBASE``) |m34| caretright (centered at base)
``10`` (``CARETUPBASE``) |m35| caretup (centered at base)
``11`` (``CARETDOWNBASE``) |m36| caretdown (centered at base)
``"None"``, ``" "`` or ``""`` nothing
``"none"`` or ``"None"`` nothing
``" "`` or ``""`` nothing
``'$...$'`` |m37| Render the string using mathtext.
E.g ``"$f$"`` for marker showing the
letter ``f``.
Expand Down Expand Up @@ -200,6 +201,7 @@ class MarkerStyle:
CARETUPBASE: 'caretupbase',
CARETDOWNBASE: 'caretdownbase',
"None": 'nothing',
"none": 'nothing',
None: 'nothing',
' ': 'nothing',
'': 'nothing'
Expand Down Expand Up @@ -227,7 +229,7 @@ def __init__(self, marker=_unset, fillstyle=None):
- Another instance of *MarkerStyle* copies the details of that
``marker``.
- *None* means no marker. This is the deprecated default.
- For other possible marker values see the module docstring
- For other possible marker values, see the module docstring
`matplotlib.markers`.

fillstyle : str, default: :rc:`markers.fillstyle`
Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4117,8 +4117,9 @@ def test_eventplot_orientation(data, orientation):
@image_comparison(['marker_styles.png'], remove_text=True)
def test_marker_styles():
fig, ax = plt.subplots()
for y, marker in enumerate(sorted(matplotlib.markers.MarkerStyle.markers,
key=lambda x: str(type(x))+str(x))):
for y, marker in enumerate(sorted(
{*matplotlib.markers.MarkerStyle.markers} - {"none"},
key=lambda x: str(type(x))+str(x))):
ax.plot((y % 2)*5 + np.arange(10)*10, np.ones(10)*10*y, linestyle='',
marker=marker, markersize=10+y/5, label=marker)

Expand Down