@@ -117,6 +117,9 @@ def __call__(self, ax, renderer):
117117 self ._transform - ax .figure .transSubfigure )
118118
119119
120+ _FORMAT_UNSET = 'None'
121+
122+
120123def _process_plot_format (fmt ):
121124 """
122125 Convert a MATLAB style color/line style format string to a (*linestyle*,
@@ -129,6 +132,10 @@ def _process_plot_format(fmt):
129132 * 'r--': red dashed lines
130133 * 'C2--': the third color in the color cycle, dashed lines
131134
135+ The format is absolute in the sense that if a linestyle or marker is not
136+ defined in *fmt*, there is no line or marker. This is expressed by
137+ returning _FORMAT_UNSET for the respective quantity.
138+
132139 See Also
133140 --------
134141 matplotlib.Line2D.lineStyles, matplotlib.colors.cnames
@@ -196,9 +203,9 @@ def _process_plot_format(fmt):
196203 if linestyle is None and marker is None :
197204 linestyle = mpl .rcParams ['lines.linestyle' ]
198205 if linestyle is None :
199- linestyle = 'None'
206+ linestyle = _FORMAT_UNSET
200207 if marker is None :
201- marker = 'None'
208+ marker = _FORMAT_UNSET
202209
203210 return linestyle , marker , color
204211
@@ -461,6 +468,21 @@ def _plot_args(self, tup, kwargs, return_kwargs=False):
461468 for prop_name , val in zip (('linestyle' , 'marker' , 'color' ),
462469 (linestyle , marker , color )):
463470 if val is not None :
471+ # check for conflicts between fmt and kwargs
472+ if (fmt .lower () != 'none'
473+ and prop_name in kwargs
474+ and val != _FORMAT_UNSET ):
475+ # Technically ``plot(x, y, 'o', ls='--')`` is a conflict
476+ # because 'o' implicitly unsets the linestyle
477+ # (linestyle=_FORMAT_UNSET).
478+ # We'll gracefully not warn in this case because an
479+ # explicit set via kwargs can be seen as intention to
480+ # override an implicit unset.
481+ _api .warn_external (
482+ f"{ prop_name } is redundantly defined by the "
483+ f"'{ prop_name } ' keyword argument and the fmt string "
484+ f'"{ fmt } " (-> { prop_name } ={ val !r} ). The keyword '
485+ f"argument will take precedence." )
464486 kw [prop_name ] = val
465487
466488 if len (xy ) == 2 :
0 commit comments