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

Skip to content

Commit 3f03e2e

Browse files
committed
Merge pull request #4198 from efiring/plot_color_alias
FIX : convert 'c' to 'color' immediately in plot closes #4162, closes #4157, closes #4262
1 parent 5852d83 commit 3f03e2e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,12 @@ def plot(self, *args, **kwargs):
13701370
self.cla()
13711371
lines = []
13721372

1373+
# Convert "c" alias to "color" immediately, to avoid
1374+
# confusion farther on.
1375+
c = kwargs.pop('c', None)
1376+
if c is not None:
1377+
kwargs['color'] = c
1378+
13731379
for line in self._get_lines(*args, **kwargs):
13741380
self.add_line(line)
13751381
lines.append(line)

lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,6 +3433,13 @@ def test_color_None():
34333433
ax.plot([1,2], [1,2], color=None)
34343434
plt.show()
34353435

3436+
@cleanup
3437+
def test_color_alias():
3438+
# issues 4157 and 4162
3439+
fig, ax = plt.subplots()
3440+
line = ax.plot([0, 1], c='lime')[0]
3441+
assert_equal('lime', line.get_color())
3442+
34363443
@cleanup
34373444
def test_numerical_hist_label():
34383445
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)