From 9d4825b1b9a3f87198aea24567891ead533f5b7c Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 14 Jan 2021 01:10:36 +0100 Subject: [PATCH] Cleanup code for format processing --- lib/matplotlib/axes/_base.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 09d2a11b688e..6e9d01a59483 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -117,9 +117,6 @@ def __call__(self, ax, renderer): self._transform - ax.figure.transSubfigure) -_FORMAT_UNSET = 'None' - - def _process_plot_format(fmt): """ Convert a MATLAB style color/line style format string to a (*linestyle*, @@ -134,7 +131,7 @@ def _process_plot_format(fmt): The format is absolute in the sense that if a linestyle or marker is not defined in *fmt*, there is no line or marker. This is expressed by - returning _FORMAT_UNSET for the respective quantity. + returning 'None' for the respective quantity. See Also -------- @@ -203,9 +200,9 @@ def _process_plot_format(fmt): if linestyle is None and marker is None: linestyle = mpl.rcParams['lines.linestyle'] if linestyle is None: - linestyle = _FORMAT_UNSET + linestyle = 'None' if marker is None: - marker = _FORMAT_UNSET + marker = 'None' return linestyle, marker, color @@ -471,13 +468,17 @@ def _plot_args(self, tup, kwargs, return_kwargs=False): # check for conflicts between fmt and kwargs if (fmt.lower() != 'none' and prop_name in kwargs - and val != _FORMAT_UNSET): + and val != 'None'): # Technically ``plot(x, y, 'o', ls='--')`` is a conflict # because 'o' implicitly unsets the linestyle - # (linestyle=_FORMAT_UNSET). + # (linestyle='None'). # We'll gracefully not warn in this case because an # explicit set via kwargs can be seen as intention to # override an implicit unset. + # Note: We don't val.lower() != 'none' because val is not + # necessarily a string (can be a tuple for colors). This + # is safe, because *val* comes from _process_plot_format() + # which only returns 'None'. _api.warn_external( f"{prop_name} is redundantly defined by the " f"'{prop_name}' keyword argument and the fmt string "