diff --git a/doc/source/v0.15.0.txt b/doc/source/v0.15.0.txt index fe1b1dcb90032..64b3427230eeb 100644 --- a/doc/source/v0.15.0.txt +++ b/doc/source/v0.15.0.txt @@ -794,6 +794,6 @@ needed interpolating (:issue:`7173`). (:issue:`8230`). - Bug with ``DatetimeIndex.asof`` incorrectly matching partial strings and returning the wrong date (:issue:`8245`). - - +- Bug in plotting methods modifying the global matplotlib +rcParams (:issue:`8242`). diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index a7e3d39692d27..96bde2d222bca 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -479,6 +479,12 @@ def test_plot_figsize_and_title(self): self._check_text_labels(ax.title, 'Test') self._check_axes_shape(ax, axes_num=1, layout=(1, 1), figsize=(16, 8)) + def test_dont_modify_rcParams(self): + # GH 8242 + colors = self.plt.rcParams['axes.color_cycle'] + Series([1, 2, 3]).plot() + self.assertEqual(colors, self.plt.rcParams['axes.color_cycle']) + def test_ts_line_lim(self): ax = self.ts.plot() xmin, xmax = ax.get_xlim() diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index a6930280e6421..190b178e37ad3 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -116,7 +116,10 @@ def _get_standard_colors(num_colors=None, colormap=None, color_type='default', colors = color else: if color_type == 'default': - colors = plt.rcParams.get('axes.color_cycle', list('bgrcmyk')) + # need to call list() on the result to copy so we don't + # modify the global rcParams below + colors = list(plt.rcParams.get('axes.color_cycle', + list('bgrcmyk'))) if isinstance(colors, compat.string_types): colors = list(colors) elif color_type == 'random':