Skip to content

Commit ed0b475

Browse files
committed
Merge pull request #6345 from WeatherGod/use_normalization
Add some kwarg normalization to plot()/fill().
2 parents e1499e1 + 8e0963d commit ed0b475

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

lib/matplotlib/axes/_axes.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@
4444

4545
rcParams = matplotlib.rcParams
4646

47+
_alias_map = {'color': ['c'],
48+
'linewidth': ['lw'],
49+
'linestyle': ['ls'],
50+
'facecolor': ['fc'],
51+
'edgecolor': ['ec'],
52+
'markerfacecolor': ['mfc'],
53+
'markeredgecolor': ['mec'],
54+
'markeredgewidth': ['mew'],
55+
'markersize': ['ms'],
56+
}
57+
4758

4859
def _plot_args_replacer(args, data):
4960
if len(args) == 1:
@@ -1415,11 +1426,7 @@ def plot(self, *args, **kwargs):
14151426
self.cla()
14161427
lines = []
14171428

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
1429+
kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
14231430

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

4547+
kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
4548+
45404549
patches = []
45414550
for poly in self._get_patches_for_fill(*args, **kwargs):
45424551
self.add_patch(poly)

lib/matplotlib/tests/test_cycles.py

+24
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'],
127+
remove_text=True, 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'],
138+
remove_text=True, 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)