@@ -117,6 +117,8 @@ def __call__(self, ax, renderer):
117
117
self ._transform - ax .figure .transSubfigure )
118
118
119
119
120
+ _FORMAT_UNSET = 'None'
121
+
120
122
def _process_plot_format (fmt ):
121
123
"""
122
124
Convert a MATLAB style color/line style format string to a (*linestyle*,
@@ -129,6 +131,10 @@ def _process_plot_format(fmt):
129
131
* 'r--': red dashed lines
130
132
* 'C2--': the third color in the color cycle, dashed lines
131
133
134
+ The format is absolute in the sense that if a linestyle or marker is not
135
+ defined in *fmt*, there is no line or marker. This is expressed by
136
+ returning _FORMAT_UNSET for the respective quantity.
137
+
132
138
See Also
133
139
--------
134
140
matplotlib.Line2D.lineStyles, matplotlib.colors.cnames
@@ -196,9 +202,9 @@ def _process_plot_format(fmt):
196
202
if linestyle is None and marker is None :
197
203
linestyle = mpl .rcParams ['lines.linestyle' ]
198
204
if linestyle is None :
199
- linestyle = 'None'
205
+ linestyle = _FORMAT_UNSET
200
206
if marker is None :
201
- marker = 'None'
207
+ marker = _FORMAT_UNSET
202
208
203
209
return linestyle , marker , color
204
210
@@ -461,6 +467,19 @@ def _plot_args(self, tup, kwargs, return_kwargs=False):
461
467
for prop_name , val in zip (('linestyle' , 'marker' , 'color' ),
462
468
(linestyle , marker , color )):
463
469
if val is not None :
470
+ # check for conflicts between fmt and kwargs
471
+ if prop_name in kwargs and val != _FORMAT_UNSET :
472
+ # Technically ``plot(x, y, 'o', ls='--')`` is a conflict
473
+ # because 'o' implicitly unsets the linestyle
474
+ # (linestyle=_FORMAT_UNSET).
475
+ # We'll gracefully not warn in this case because an
476
+ # explicit set via kwargs can be seen as intention to
477
+ # override an implicit unset.
478
+ _api .warn_external (
479
+ f"{ prop_name } is redundantly defined by the "
480
+ f"'{ prop_name } ' keyword argument and the fmt string "
481
+ f'"{ fmt } " (-> { prop_name } ={ val !r} ). The keyword '
482
+ f"argument will take precedence." )
464
483
kw [prop_name ] = val
465
484
466
485
if len (xy ) == 2 :
0 commit comments