@@ -117,6 +117,9 @@ def __call__(self, ax, renderer):
117
117
self ._transform - ax .figure .transSubfigure )
118
118
119
119
120
+ _FORMAT_UNSET = 'None'
121
+
122
+
120
123
def _process_plot_format (fmt ):
121
124
"""
122
125
Convert a MATLAB style color/line style format string to a (*linestyle*,
@@ -129,6 +132,10 @@ def _process_plot_format(fmt):
129
132
* 'r--': red dashed lines
130
133
* 'C2--': the third color in the color cycle, dashed lines
131
134
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
+
132
139
See Also
133
140
--------
134
141
matplotlib.Line2D.lineStyles, matplotlib.colors.cnames
@@ -196,9 +203,9 @@ def _process_plot_format(fmt):
196
203
if linestyle is None and marker is None :
197
204
linestyle = mpl .rcParams ['lines.linestyle' ]
198
205
if linestyle is None :
199
- linestyle = 'None'
206
+ linestyle = _FORMAT_UNSET
200
207
if marker is None :
201
- marker = 'None'
208
+ marker = _FORMAT_UNSET
202
209
203
210
return linestyle , marker , color
204
211
@@ -461,6 +468,21 @@ def _plot_args(self, tup, kwargs, return_kwargs=False):
461
468
for prop_name , val in zip (('linestyle' , 'marker' , 'color' ),
462
469
(linestyle , marker , color )):
463
470
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." )
464
486
kw [prop_name ] = val
465
487
466
488
if len (xy ) == 2 :
0 commit comments