Skip to content

Deprecate color keyword argument in scatter #4675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
8 changes: 8 additions & 0 deletions doc/api/api_changes/2015-07-13_scatter_color_kwarg.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Deprecated the 'color' keyword argument to scatter
``````````````````````````````````````````````````

The ``scatter`` function takes a ``color`` keyword argument, but this argument
is not defined in the documentation, and there was a comment in the code
suggesting it should be deprecated. Thus, the argument has been deprecated and
removed from the examples; instead, users should use the ``c`` keyword argument
to set the color of the scatter points.
4 changes: 2 additions & 2 deletions doc/users/plotting/examples/annotate_text_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
x2 = 1. + numpy.random.randn(100)
y2 = 1. + numpy.random.randn(100)

ax.scatter(x1, y1, color="r")
ax.scatter(x2, y2, color="g")
ax.scatter(x1, y1, c="r")
ax.scatter(x2, y2, c="g")

bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.9)
ax.text(-2, -2, "Sample A", ha="center", va="center", size=20,
Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/subplots_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
ax1.plot(x, y)
ax1.set_title('Sharing both axes')
ax2.scatter(x, y)
ax3.scatter(x, 2 * y ** 2 - 1, color='r')
ax3.scatter(x, 2 * y ** 2 - 1, c='r')
# Fine-tune figure; make subplots close to each other and hide x ticks for
# all but bottom plot.
f.subplots_adjust(hspace=0)
Expand All @@ -48,7 +48,7 @@
ax1.plot(x, y)
ax1.set_title('Sharing x per column, y per row')
ax2.scatter(x, y)
ax3.scatter(x, 2 * y ** 2 - 1, color='r')
ax3.scatter(x, 2 * y ** 2 - 1, c='r')
ax4.plot(x, 2 * y ** 2 - 1, color='r')

# Four axes, returned as a 2-d array
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3672,6 +3672,11 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
# since it isn't, I am giving it low priority.
co = kwargs.pop('color', None)
if co is not None:
msg = (
"The 'color' keyword argument to scatter is deprecated, "
"please use 'c' instead."
)
warnings.warn(msg, mplDeprecation, stacklevel=1)
if edgecolors is None:
edgecolors = co
if facecolors is None:
Expand Down