Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3f03e2e

Browse filesBrowse 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
Copy full SHA for 3f03e2e

File tree

Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+6Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+7Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.