X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3824,19 +3824,20 @@ def scatter(self, x, y, s=None, c=None, marker='o', cmap=None, norm=None,
# Process **kwargs to handle aliases, conflicts with explicit kwargs:

facecolors = None
ec = kwargs.pop('edgecolor', None)
if ec is not None:
edgecolors = ec
fc = kwargs.pop('facecolor', None)
if fc is not None:
facecolors = fc
edgecolors = kwargs.pop('edgecolor', edgecolors)
fc = kwargs.pop('facecolors', None)
fc = kwargs.pop('facecolor', fc)
if fc is not None:
facecolors = fc
# 'color' should be deprecated in scatter, or clearly defined;
# since it isn't, I am giving it low priority.
co = kwargs.pop('color', None)
if co is not None:
try:
mcolors.colorConverter.to_rgba_array(co)
except ValueError:
raise ValueError("'color' kwarg must be an mpl color"
" spec or sequence of color specs.\n"
"For a sequence of values to be"
" color-mapped, use the 'c' kwarg instead.")
if edgecolors is None:
edgecolors = co
if facecolors is None:
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,13 @@ def test_scatter_2D():
fig, ax = plt.subplots()
ax.scatter(x, y, c=z, s=200, edgecolors='face')

@cleanup
def test_scatter_color():
# Try to catch cases where 'c' kwarg should have been used.
assert_raises(ValueError, plt.scatter, [1, 2], [1, 2],
color=[0.1, 0.2])
assert_raises(ValueError, plt.scatter, [1, 2, 3], [1, 2, 3],
color=[1, 2, 3])

@cleanup
def test_as_mpl_axes_api():
Expand Down
X Tutup