Skip to content

Commit

Permalink
Remove support for upper case color strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed Apr 25, 2020
1 parent e9eb00c commit 462eb5f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
6 changes: 6 additions & 0 deletions doc/api/api_changes_3.3/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,9 @@ Passing Line2D's *drawstyle* together with *linestyle* is removed
Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(...,
linestyle="--", drawstyle="steps")``. ``ds`` is also an alias for
``drawstyle``.

Upper case color strings
~~~~~~~~~~~~~~~~~~~~~~~~

Support for passing single-letter colors (one of "rgbcmykw") as UPPERCASE
characters is removed; these colors are now case-sensitive (lowercase).
16 changes: 5 additions & 11 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,11 @@ def _to_rgba_no_colorcycle(c, alpha=None):
# This may turn c into a non-string, so we check again below.
c = _colors_full_map[c]
except KeyError:
try:
c = _colors_full_map[c.lower()]
except KeyError:
pass
else:
if len(orig_c) == 1:
cbook.warn_deprecated(
"3.1", message="Support for uppercase "
"single-letter colors is deprecated since Matplotlib "
"%(since)s and will be removed %(removal)s; please "
"use lowercase instead.")
if len(orig_c) != 1:
try:
c = _colors_full_map[c.lower()]
except KeyError:
pass
if isinstance(c, str):
# hex color in #rrggbb format.
match = re.match(r"\A#[a-fA-F0-9]{6}\Z", c)
Expand Down
8 changes: 0 additions & 8 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5650,14 +5650,6 @@ def test_annotate_across_transforms():
arrowprops=dict(arrowstyle="->"))


def test_deprecated_uppercase_colors():
# Remove after end of deprecation period.
fig, ax = plt.subplots()
with pytest.warns(MatplotlibDeprecationWarning):
ax.plot([1, 2], color="B")
fig.canvas.draw()


@image_comparison(['secondary_xy.png'], style='mpl20')
def test_secondary_xy():
fig, axs = plt.subplots(1, 2, figsize=(10, 5), constrained_layout=True)
Expand Down

0 comments on commit 462eb5f

Please sign in to comment.