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

Fix the resetting of color cycles #5536

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

Merged
merged 1 commit into from
Nov 24, 2015
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
Fix the resetting of color cycles
  • Loading branch information
WeatherGod committed Nov 20, 2015
commit eed693fcbe3ef29bb7f4314782e197c36f10e29d
8 changes: 7 additions & 1 deletion 8 lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,13 @@ def set_color_cycle(self, clist):
"""
cbook.warn_deprecated(
'1.5', name='set_color_cycle', alternative='set_prop_cycle')
self.set_prop_cycle('color', clist)
if clist is None:
# Calling set_color_cycle() or set_prop_cycle() with None
# effectively resets the cycle, but you can't do
# set_prop_cycle('color', None). So we are special-casing this.
self.set_prop_cycle(None)
else:
self.set_prop_cycle('color', clist)

def ishold(self):
"""return the HOLD status of the axes"""
Expand Down
26 changes: 26 additions & 0 deletions 26 lib/matplotlib/tests/test_cycles.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

from matplotlib.testing.decorators import image_comparison, cleanup
import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -147,6 +149,30 @@ def test_valid_input_forms():
assert True


@cleanup
def test_cycle_reset():
fig, ax = plt.subplots()

# Can't really test a reset because only a cycle object is stored
# but we can test the first item of the cycle.
prop = next(ax._get_lines.prop_cycler)
ax.set_prop_cycle(linewidth=[10, 9, 4])
assert prop != next(ax._get_lines.prop_cycler)
ax.set_prop_cycle(None)
got = next(ax._get_lines.prop_cycler)
assert prop == got, "expected %s, got %s" % (prop, got)

fig, ax = plt.subplots()
# Need to double-check the old set/get_color_cycle(), too
with warnings.catch_warnings():
prop = next(ax._get_lines.prop_cycler)
ax.set_color_cycle(['c', 'm', 'y', 'k'])
assert prop != next(ax._get_lines.prop_cycler)
ax.set_color_cycle(None)
got = next(ax._get_lines.prop_cycler)
assert prop == got, "expected %s, got %s" % (prop, got)


@cleanup
def test_invalid_input_forms():
fig, ax = plt.subplots()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.