Skip to content

Commit da2457d

Browse files
committed
Add some kwarg normalization to plot()/fill().
1 parent 1f1b8b8 commit da2457d

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,11 +1415,18 @@ def plot(self, *args, **kwargs):
14151415
self.cla()
14161416
lines = []
14171417

1418-
# Convert "c" alias to "color" immediately, to avoid
1419-
# confusion farther on.
1420-
c = kwargs.pop('c', None)
1421-
if c is not None:
1422-
kwargs['color'] = c
1418+
kwargs = cbook.normalize_kwargs(kwargs,
1419+
{
1420+
'color': ['c'],
1421+
'linewidth': ['lw'],
1422+
'linestyle': ['ls'],
1423+
'facecolor': ['fc'],
1424+
'edgecolor': ['ec'],
1425+
'markerfacecolor': ['mfc'],
1426+
'markeredgecolor': ['mec'],
1427+
'markeredgewidth': ['mew'],
1428+
'markersize': ['ms'],
1429+
})
14231430

14241431
for line in self._get_lines(*args, **kwargs):
14251432
self.add_line(line)
@@ -4537,6 +4544,19 @@ def fill(self, *args, **kwargs):
45374544
if not self._hold:
45384545
self.cla()
45394546

4547+
kwargs = cbook.normalize_kwargs(kwargs,
4548+
{
4549+
'color': ['c'],
4550+
'linewidth': ['lw'],
4551+
'linestyle': ['ls'],
4552+
'facecolor': ['fc'],
4553+
'edgecolor': ['ec'],
4554+
'markerfacecolor': ['mfc'],
4555+
'markeredgecolor': ['mec'],
4556+
'markeredgewidth': ['mew'],
4557+
'markersize': ['ms'],
4558+
})
4559+
45404560
patches = []
45414561
for poly in self._get_patches_for_fill(*args, **kwargs):
45424562
self.add_patch(poly)

lib/matplotlib/tests/test_cycles.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,30 @@ def test_fillcycle_ignore():
123123
ax.legend(loc='upper left')
124124

125125

126+
@image_comparison(baseline_images=['property_collision_plot'], remove_text=True,
127+
extensions=['png'])
128+
def test_property_collision_plot():
129+
fig, ax = plt.subplots()
130+
ax.set_prop_cycle('linewidth', [2, 4])
131+
for c in range(1, 4):
132+
ax.plot(np.arange(10), c * np.arange(10), lw=0.1)
133+
ax.plot(np.arange(10), 4 * np.arange(10))
134+
ax.plot(np.arange(10), 5 * np.arange(10))
135+
136+
137+
@image_comparison(baseline_images=['property_collision_fill'], remove_text=True,
138+
extensions=['png'])
139+
def test_property_collision_fill():
140+
fig, ax = plt.subplots()
141+
xs = np.arange(10)
142+
ys = 0.25 * xs**.5 + 2
143+
ax.set_prop_cycle(linewidth=[2, 3, 4, 5, 6], facecolor='bgcmy')
144+
for c in range(1, 4):
145+
ax.fill(xs, c * ys, lw=0.1)
146+
ax.fill(xs, 4 * ys)
147+
ax.fill(xs, 5 * ys)
148+
149+
126150
@cleanup
127151
def test_valid_input_forms():
128152
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)