Skip to content

Commit e374f0f

Browse files
committed
BUG: axes.color_cycle from mpl rcParams should not be joined as single string
1 parent bf538a9 commit e374f0f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: pandas/tests/test_graphics.py

+15
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,21 @@ def test_line_colors(self):
537537
plt.close('all')
538538
df.ix[:, [0]].plot(color='DodgerBlue')
539539

540+
@slow
541+
def test_default_color_cycle(self):
542+
import matplotlib.pyplot as plt
543+
plt.rcParams['axes.color_cycle'] = list('rgbk')
544+
545+
plt.close('all')
546+
df = DataFrame(np.random.randn(5, 3))
547+
ax = df.plot()
548+
549+
lines = ax.get_lines()
550+
for i, l in enumerate(lines):
551+
xp = plt.rcParams['axes.color_cycle'][i]
552+
rs = l.get_color()
553+
self.assert_(xp == rs)
554+
540555

541556
class TestDataFrameGroupByPlots(unittest.TestCase):
542557

Diff for: pandas/tools/plotting.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,9 @@ def _use_dynamic_x(self):
979979

980980
def _get_colors(self):
981981
import matplotlib.pyplot as plt
982-
cycle = ''.join(plt.rcParams.get('axes.color_cycle', list('bgrcmyk')))
982+
cycle = plt.rcParams.get('axes.color_cycle', list('bgrcmyk'))
983+
if isinstance(cycle, basestring):
984+
cycle = list(cycle)
983985
has_colors = 'color' in self.kwds
984986
colors = self.kwds.get('color', cycle)
985987
return colors

0 commit comments

Comments
 (0)