Skip to content

Commit c73d353

Browse files
committed
Cleanup code for format processing
1 parent 2219872 commit c73d353

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/matplotlib/axes/_base.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ def __call__(self, ax, renderer):
117117
self._transform - ax.figure.transSubfigure)
118118

119119

120-
_FORMAT_UNSET = 'None'
121-
122-
123120
def _process_plot_format(fmt):
124121
"""
125122
Convert a MATLAB style color/line style format string to a (*linestyle*,
@@ -134,7 +131,7 @@ def _process_plot_format(fmt):
134131
135132
The format is absolute in the sense that if a linestyle or marker is not
136133
defined in *fmt*, there is no line or marker. This is expressed by
137-
returning _FORMAT_UNSET for the respective quantity.
134+
returning 'none' for the respective quantity.
138135
139136
See Also
140137
--------
@@ -203,9 +200,9 @@ def _process_plot_format(fmt):
203200
if linestyle is None and marker is None:
204201
linestyle = mpl.rcParams['lines.linestyle']
205202
if linestyle is None:
206-
linestyle = _FORMAT_UNSET
203+
linestyle = 'none'
207204
if marker is None:
208-
marker = _FORMAT_UNSET
205+
marker = 'none'
209206

210207
return linestyle, marker, color
211208

@@ -471,13 +468,17 @@ def _plot_args(self, tup, kwargs, return_kwargs=False):
471468
# check for conflicts between fmt and kwargs
472469
if (fmt.lower() != 'none'
473470
and prop_name in kwargs
474-
and val != _FORMAT_UNSET):
471+
and val != 'none'):
475472
# Technically ``plot(x, y, 'o', ls='--')`` is a conflict
476473
# because 'o' implicitly unsets the linestyle
477-
# (linestyle=_FORMAT_UNSET).
474+
# (linestyle='none').
478475
# We'll gracefully not warn in this case because an
479476
# explicit set via kwargs can be seen as intention to
480477
# override an implicit unset.
478+
# Note: We don't val.lower() != 'none' because val is not
479+
# necessarily a string (can be a tuple for colors). This
480+
# is safe, because *val* comes from _process_plot_format()
481+
# which only returns lowercase 'none'.
481482
_api.warn_external(
482483
f"{prop_name} is redundantly defined by the "
483484
f"'{prop_name}' keyword argument and the fmt string "

0 commit comments

Comments
 (0)