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 308fae5

Browse filesBrowse files
committed
Plot: convert 'c' to 'color' immediately; closes #4162, #4157
1 parent 4f80cfd commit 308fae5
Copy full SHA for 308fae5

File tree

Expand file treeCollapse file tree

2 files changed

+17
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-4
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
@@ -1366,6 +1366,12 @@ def plot(self, *args, **kwargs):
13661366
self.cla()
13671367
lines = []
13681368

1369+
# Convert "c" alias to "color" immediately, to avoid
1370+
# confusion farther on.
1371+
c = kwargs.pop('c', None)
1372+
if c is not None:
1373+
kwargs['color'] = c
1374+
13691375
for line in self._get_lines(*args, **kwargs):
13701376
self.add_line(line)
13711377
lines.append(line)

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,10 +3492,10 @@ def test_set_get_ticklabels():
34923492
# set ticklabel to 1 plot in normal way
34933493
ax[0].set_xticklabels(('a', 'b', 'c', 'd'))
34943494
ax[0].set_yticklabels(('11', '12', '13', '14'))
3495-
3495+
34963496
# set ticklabel to the other plot, expect the 2 plots have same label setting
3497-
# pass get_ticklabels return value as ticklabels argument
3498-
ax[1].set_xticklabels(ax[0].get_xticklabels() )
3497+
# pass get_ticklabels return value as ticklabels argument
3498+
ax[1].set_xticklabels(ax[0].get_xticklabels() )
34993499
ax[1].set_yticklabels(ax[0].get_yticklabels() )
35003500

35013501

@@ -3545,11 +3545,18 @@ def test_color_None():
35453545
fig, ax = plt.subplots()
35463546
ax.plot([1,2], [1,2], color=None)
35473547

3548+
@cleanup
3549+
def test_color_alias():
3550+
# issues 4157 and 4162
3551+
fig, ax = plt.subplots()
3552+
line = ax.plot([0, 1], c='lime')[0]
3553+
assert_equal('lime', line.get_color())
3554+
35483555
@cleanup
35493556
def test_numerical_hist_label():
35503557
fig, ax = plt.subplots()
35513558
ax.hist([range(15)] * 5, label=range(5))
3552-
3559+
35533560
@cleanup
35543561
def test_move_offsetlabel():
35553562
data = np.random.random(10) * 1e-22

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.