Skip to content

Commit abd5333

Browse files
author
Tom Augspurger
committed
Merge pull request #8249 from TomAugspurger/color-cycle
BUG: plot methods modified rcParams
2 parents 13514dc + 86c214e commit abd5333

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

doc/source/v0.15.0.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,6 @@ needed interpolating (:issue:`7173`).
794794
(:issue:`8230`).
795795
- Bug with ``DatetimeIndex.asof`` incorrectly matching partial strings and
796796
returning the wrong date (:issue:`8245`).
797-
798-
797+
- Bug in plotting methods modifying the global matplotlib
798+
rcParams (:issue:`8242`).
799799

pandas/tests/test_graphics.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@ def test_plot_figsize_and_title(self):
479479
self._check_text_labels(ax.title, 'Test')
480480
self._check_axes_shape(ax, axes_num=1, layout=(1, 1), figsize=(16, 8))
481481

482+
def test_dont_modify_rcParams(self):
483+
# GH 8242
484+
colors = self.plt.rcParams['axes.color_cycle']
485+
Series([1, 2, 3]).plot()
486+
self.assertEqual(colors, self.plt.rcParams['axes.color_cycle'])
487+
482488
def test_ts_line_lim(self):
483489
ax = self.ts.plot()
484490
xmin, xmax = ax.get_xlim()

pandas/tools/plotting.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def _get_standard_colors(num_colors=None, colormap=None, color_type='default',
116116
colors = color
117117
else:
118118
if color_type == 'default':
119-
colors = plt.rcParams.get('axes.color_cycle', list('bgrcmyk'))
119+
# need to call list() on the result to copy so we don't
120+
# modify the global rcParams below
121+
colors = list(plt.rcParams.get('axes.color_cycle',
122+
list('bgrcmyk')))
120123
if isinstance(colors, compat.string_types):
121124
colors = list(colors)
122125
elif color_type == 'random':

0 commit comments

Comments
 (0)