Skip to content

Commit c7748ca

Browse files
datapythonistajreback
authored andcommitted
PLOT: Split matplotlib specific code from pandas plotting (#26414)
1 parent b9a7f61 commit c7748ca

25 files changed

+2961
-2793
lines changed

asv_bench/benchmarks/timeseries.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pandas import to_datetime, date_range, Series, DataFrame, period_range
66
from pandas.tseries.frequencies import infer_freq
77
try:
8-
from pandas.plotting._converter import DatetimeConverter
8+
from pandas.plotting._matplotlib.converter import DatetimeConverter
99
except ImportError:
1010
from pandas.tseries.converter import DatetimeConverter
1111

pandas/core/frame.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
from pandas.io.formats import format as fmt
102102
from pandas.io.formats.printing import pprint_thing
103103

104-
import pandas.plotting._core as gfx
104+
import pandas.plotting
105105

106106
# ---------------------------------------------------------------------
107107
# Docstring templates
@@ -8041,9 +8041,9 @@ def isin(self, values):
80418041

80428042
# ----------------------------------------------------------------------
80438043
# Add plotting methods to DataFrame
8044-
plot = CachedAccessor("plot", gfx.FramePlotMethods)
8045-
hist = gfx.hist_frame
8046-
boxplot = gfx.boxplot_frame
8044+
plot = CachedAccessor("plot", pandas.plotting.FramePlotMethods)
8045+
hist = pandas.plotting.hist_frame
8046+
boxplot = pandas.plotting.boxplot_frame
80478047
sparse = CachedAccessor("sparse", SparseFrameAccessor)
80488048

80498049

pandas/core/groupby/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from pandas.core.series import Series
4242
from pandas.core.sparse.frame import SparseDataFrame
4343

44-
from pandas.plotting._core import boxplot_frame_groupby
44+
from pandas.plotting import boxplot_frame_groupby
4545

4646
NamedAgg = namedtuple("NamedAgg", ["column", "aggfunc"])
4747
# TODO(typing) the return value on this callable should be any *scalar*.

pandas/core/series.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from pandas.core.tools.datetimes import to_datetime
5050

5151
import pandas.io.formats.format as fmt
52-
import pandas.plotting._core as gfx
52+
import pandas.plotting
5353

5454
__all__ = ['Series']
5555

@@ -4502,12 +4502,12 @@ def to_period(self, freq=None, copy=True):
45024502
str = CachedAccessor("str", StringMethods)
45034503
dt = CachedAccessor("dt", CombinedDatetimelikeProperties)
45044504
cat = CachedAccessor("cat", CategoricalAccessor)
4505-
plot = CachedAccessor("plot", gfx.SeriesPlotMethods)
4505+
plot = CachedAccessor("plot", pandas.plotting.SeriesPlotMethods)
45064506
sparse = CachedAccessor("sparse", SparseAccessor)
45074507

45084508
# ----------------------------------------------------------------------
45094509
# Add plotting methods to Series
4510-
hist = gfx.hist_series
4510+
hist = pandas.plotting.hist_series
45114511

45124512

45134513
Series._setup_axes(['index'], info_axis=0, stat_axis=0, aliases={'rows': 0},

pandas/plotting/__init__.py

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
"""
2-
Plotting api
2+
Plotting public API
33
"""
4+
from pandas.plotting._core import (
5+
FramePlotMethods, SeriesPlotMethods, boxplot, boxplot_frame,
6+
boxplot_frame_groupby, hist_frame, hist_series)
7+
from pandas.plotting._misc import (
8+
andrews_curves, autocorrelation_plot, bootstrap_plot,
9+
deregister as deregister_matplotlib_converters, lag_plot,
10+
parallel_coordinates, plot_params, radviz,
11+
register as register_matplotlib_converters, scatter_matrix, table)
412

5-
# flake8: noqa
6-
7-
from pandas.plotting._misc import (scatter_matrix, radviz,
8-
andrews_curves, bootstrap_plot,
9-
parallel_coordinates, lag_plot,
10-
autocorrelation_plot)
11-
from pandas.plotting._core import boxplot
12-
from pandas.plotting._style import plot_params
13-
from pandas.plotting._tools import table
14-
try:
15-
from pandas.plotting._converter import (
16-
register as register_matplotlib_converters)
17-
from pandas.plotting._converter import (
18-
deregister as deregister_matplotlib_converters)
19-
except ImportError:
20-
pass
13+
__all__ = ['boxplot', 'boxplot_frame', 'boxplot_frame_groupby', 'hist_frame',
14+
'hist_series', 'FramePlotMethods', 'SeriesPlotMethods',
15+
'scatter_matrix', 'radviz', 'andrews_curves', 'bootstrap_plot',
16+
'parallel_coordinates', 'lag_plot', 'autocorrelation_plot',
17+
'table', 'plot_params', 'register_matplotlib_converters',
18+
'deregister_matplotlib_converters']

0 commit comments

Comments
 (0)