Skip to content

Commit 0d146f9

Browse files
author
Marc Garcia
committed
Fixing bug that made reusing the previous plot for dataframes
1 parent 369fbf1 commit 0d146f9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pandas/plotting/_core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ def __call__(self, *args, **kwargs):
215215
plot_backend = _get_plot_backend()
216216
data = self._parent.copy()
217217

218+
if isinstance(data, pandas.core.dtypes.generic.ABCSeries):
219+
kwargs['new_plot'] = True
220+
218221
if kind in self._dataframe_kinds:
219222
if isinstance(data, ABCDataFrame):
220223
return plot_backend.plot(data, x=x, y=y, kind=kind, **kwargs)

pandas/plotting/_matplotlib/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from pandas._config import get_option
44

5-
import pandas
6-
75
from pandas.plotting._matplotlib.boxplot import (
86
BoxPlot, boxplot, boxplot_frame, boxplot_frame_groupby)
97
from pandas.plotting._matplotlib.converter import deregister, register
@@ -33,7 +31,7 @@
3331

3432

3533
def plot(data, kind, **kwargs):
36-
if isinstance(data, pandas.core.dtypes.generic.ABCSeries):
34+
if kwargs.pop('new_plot', False):
3735
ax = kwargs.get('ax')
3836
if ax is None and len(plt.get_fignums()) > 0:
3937
with plt.rc_context():

0 commit comments

Comments
 (0)