Skip to content

Commit ac335d9

Browse files
committed
Merge pull request #4198 from efiring/plot_color_alias
FIX : convert 'c' to 'color' immediately in plot closes #4162, closes #4157
2 parents 4f80cfd + 308fae5 commit ac335d9

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/matplotlib/axes/_axes.py

+6
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

+11-4
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)