Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b8e39f9

Browse files
committed
Make set_marker{edge,face}color(None) more consistent.
Resolving None to mean "the rcParam" is both consistent with the behavior in `__init__` (which manually maps None to the rcParam) and with markeredgewidth. In particular, being consistent with `__init__` ensures that in ``` from pylab import *; from matplotlib.lines import Line2D rcParams["lines.markerfacecolor"] = "red" gca().add_artist(Line2D([.1, .9], [.1, .9], marker="o", markerfacecolor=None)) gca().add_artist(Line2D([.1, .9], [.9, .1], marker="o", mfc=None)) ``` both lines use "red" as markerfacecolor (previously, the second one would go through the setter and use "auto" (i.e. the line's color) instead). I guess this should have been done when the rcParams were added in 1d9880c, but missed back then. (No change for markerfacecoloralt because there's no corresponding rcParam; perhaps one should be added just for completeness?)
1 parent a9c5224 commit b8e39f9

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``Line2D.set_markeredgecolor(None)`` and ``Line2D.set_markerfacecolor(None)``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... now set the line property using the corresponding rcParam
4+
(:rc:`lines.markeredgecolor` and :rc:`lines.markerfacecolor`). This is
5+
consistent with other `.Line2D` property setters.

lib/matplotlib/lines.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,6 @@ def __init__(self, xdata, ydata,
321321
linestyle = rcParams['lines.linestyle']
322322
if marker is None:
323323
marker = rcParams['lines.marker']
324-
if markerfacecolor is None:
325-
markerfacecolor = rcParams['lines.markerfacecolor']
326-
if markeredgecolor is None:
327-
markeredgecolor = rcParams['lines.markeredgecolor']
328324
if color is None:
329325
color = rcParams['lines.color']
330326

@@ -386,9 +382,9 @@ def __init__(self, xdata, ydata,
386382
self._markerfacecolor = None
387383
self._markerfacecoloralt = None
388384

389-
self.set_markerfacecolor(markerfacecolor)
385+
self.set_markerfacecolor(markerfacecolor) # Normalizes None to rc.
390386
self.set_markerfacecoloralt(markerfacecoloralt)
391-
self.set_markeredgecolor(markeredgecolor)
387+
self.set_markeredgecolor(markeredgecolor) # Normalizes None to rc.
392388
self.set_markeredgewidth(markeredgewidth)
393389

394390
# update kwargs before updating data to give the caller a
@@ -1146,9 +1142,10 @@ def set_marker(self, marker):
11461142
self._marker = MarkerStyle(marker, self._marker.get_fillstyle())
11471143
self.stale = True
11481144

1149-
def _set_markercolor(self, attr, val):
1145+
def _set_markercolor(self, name, has_rcdefault, val):
11501146
if val is None:
1151-
val = 'auto'
1147+
val = rcParams[f"lines.{name}"] if has_rcdefault else "auto"
1148+
attr = f"_{name}"
11521149
current = getattr(self, attr)
11531150
if current is None:
11541151
self.stale = True
@@ -1167,7 +1164,7 @@ def set_markeredgecolor(self, ec):
11671164
----------
11681165
ec : color
11691166
"""
1170-
self._set_markercolor("_markeredgecolor", ec)
1167+
self._set_markercolor("markeredgecolor", True, ec)
11711168

11721169
def set_markerfacecolor(self, fc):
11731170
"""
@@ -1177,7 +1174,7 @@ def set_markerfacecolor(self, fc):
11771174
----------
11781175
fc : color
11791176
"""
1180-
self._set_markercolor("_markerfacecolor", fc)
1177+
self._set_markercolor("markerfacecolor", True, fc)
11811178

11821179
def set_markerfacecoloralt(self, fc):
11831180
"""
@@ -1187,7 +1184,7 @@ def set_markerfacecoloralt(self, fc):
11871184
----------
11881185
fc : color
11891186
"""
1190-
self._set_markercolor("_markerfacecoloralt", fc)
1187+
self._set_markercolor("markerfacecoloralt", False, fc)
11911188

11921189
def set_markeredgewidth(self, ew):
11931190
"""

0 commit comments

Comments
 (0)