Skip to content

Commit e9c407e

Browse files
committed
Reinstante _unpack_cycler
1 parent b2cffb4 commit e9c407e

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

pandas/tests/plotting/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,12 @@ def is_grid_on():
493493
obj.plot(kind=kind, grid=True, **kws)
494494
assert is_grid_on()
495495

496+
def _unpack_cycler(self, rcParams, field='color'):
497+
"""
498+
Auxiliary function for correctly unpacking cycler after MPL >= 1.5
499+
"""
500+
return [v[field] for v in rcParams['axes.prop_cycle']]
501+
496502

497503
def _check_plot_works(f, filterwarnings='always', **kwargs):
498504
import matplotlib.pyplot as plt

pandas/tests/plotting/test_frame.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ def test_area_lim(self):
847847
@pytest.mark.slow
848848
def test_bar_colors(self):
849849
import matplotlib.pyplot as plt
850-
default_colors = [v['color'] for v in plt.rcParams['axes.prop_cycle']]
850+
default_colors = self._unpack_cycler(plt.rcParams)
851851

852852
df = DataFrame(randn(5, 5))
853853
ax = df.plot.bar()
@@ -1218,8 +1218,7 @@ def test_scatter_colors(self):
12181218
with pytest.raises(TypeError):
12191219
df.plot.scatter(x='a', y='b', c='c', color='green')
12201220

1221-
default_colors = [v['color']
1222-
for v in self.plt.rcParams['axes.prop_cycle']]
1221+
default_colors = self._unpack_cycler(self.plt.rcParams)
12231222

12241223
ax = df.plot.scatter(x='a', y='b', c='c')
12251224
tm.assert_numpy_array_equal(
@@ -1883,8 +1882,7 @@ def test_dont_modify_colors(self):
18831882
def test_line_colors_and_styles_subplots(self):
18841883
# GH 9894
18851884
from matplotlib import cm
1886-
default_colors = [v['color']
1887-
for v in self.plt.rcParams['axes.prop_cycle']]
1885+
default_colors = self._unpack_cycler(self.plt.rcParams)
18881886

18891887
df = DataFrame(randn(5, 5))
18901888

@@ -2004,8 +2002,7 @@ def test_area_colors(self):
20042002

20052003
@pytest.mark.slow
20062004
def test_hist_colors(self):
2007-
default_colors = [v['color']
2008-
for v in self.plt.rcParams['axes.prop_cycle']]
2005+
default_colors = self._unpack_cycler(self.plt.rcParams)
20092006

20102007
df = DataFrame(randn(5, 5))
20112008
ax = df.plot.hist()
@@ -2066,8 +2063,7 @@ def test_kde_colors_and_styles_subplots(self):
20662063
_skip_if_no_scipy_gaussian_kde()
20672064

20682065
from matplotlib import cm
2069-
default_colors = [v['color']
2070-
for v in self.plt.rcParams['axes.prop_cycle']]
2066+
default_colors = self._unpack_cycler(self.plt.rcParams)
20712067

20722068
df = DataFrame(randn(5, 5))
20732069

@@ -2138,8 +2134,7 @@ def _check_colors(bp, box_c, whiskers_c, medians_c, caps_c='k',
21382134
self._check_colors(bp['caps'],
21392135
linecolors=[caps_c] * len(bp['caps']))
21402136

2141-
default_colors = [v['color']
2142-
for v in self.plt.rcParams['axes.prop_cycle']]
2137+
default_colors = self._unpack_cycler(self.plt.rcParams)
21432138

21442139
df = DataFrame(randn(5, 5))
21452140
bp = df.plot.box(return_type='dict')
@@ -2195,7 +2190,7 @@ def test_default_color_cycle(self):
21952190
df = DataFrame(randn(5, 3))
21962191
ax = df.plot()
21972192

2198-
expected = [v['color'] for v in plt.rcParams['axes.prop_cycle']][:3]
2193+
expected = self._unpack_cycler(plt.rcParams)[:3]
21992194
self._check_colors(ax.get_lines(), linecolors=expected)
22002195

22012196
def test_unordered_ts(self):

pandas/tests/plotting/test_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ def test_time_series_plot_color_kwargs(self):
849849
def test_time_series_plot_color_with_empty_kwargs(self):
850850
import matplotlib as mpl
851851

852-
def_colors = [v['color'] for v in mpl.rcParams['axes.prop_cycle']]
852+
def_colors = self._unpack_cycler(mpl.rcParams)
853853
index = date_range('1/1/2000', periods=12)
854854
s = Series(np.arange(1, 13), index=index)
855855

0 commit comments

Comments
 (0)