Skip to content

BUG: plot methods modified rcParams #8249

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
Sep 12, 2014
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
4 changes: 2 additions & 2 deletions doc/source/v0.15.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`).

6 changes: 6 additions & 0 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down