Skip to content

Commit 1af0ba5

Browse files
committed
cleanup import route
1 parent 15800e3 commit 1af0ba5

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

pandas/plotting/_core.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
from pandas.core.dtypes.common import is_integer, is_list_like
66
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
77

8-
import pandas
98
from pandas.core.base import PandasObject
109
from pandas.core.generic import _shared_doc_kwargs, _shared_docs
1110

12-
# Automatically registering converters was deprecated in 0.21, but
13-
# the deprecation warning wasn't showing until 0.24
14-
# This block will be eventually removed, but it's not clear when
15-
if pandas.get_option('plotting.matplotlib.register_converters'):
16-
try:
17-
from ._misc import register
18-
register(explicit=False)
19-
except ImportError:
20-
pass
11+
# Trigger matplotlib import, which implicitly registers our
12+
# converts. Implicit registration is deprecated, and when enforced
13+
# we can lazily import matplotlib.
14+
try:
15+
import pandas.plotting._matplotlib # noqa
16+
except ImportError:
17+
pass
2118

2219
df_kind = """- 'scatter' : scatter plot
2320
- 'hexbin' : hexbin plot"""

pandas/plotting/_matplotlib/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pandas._config import get_option
2+
13
from pandas.plotting._matplotlib.boxplot import (
24
BoxPlot, boxplot, boxplot_frame, boxplot_frame_groupby)
35
from pandas.plotting._matplotlib.converter import deregister, register
@@ -11,6 +13,10 @@
1113
from pandas.plotting._matplotlib.timeseries import tsplot
1214
from pandas.plotting._matplotlib.tools import table
1315

16+
if get_option("plotting.matplotlib.register_converters"):
17+
register(explicit=False)
18+
19+
1420
__all__ = ['LinePlot', 'BarPlot', 'BarhPlot', 'HistPlot', 'BoxPlot', 'KdePlot',
1521
'AreaPlot', 'PiePlot', 'ScatterPlot', 'HexBinPlot', 'hist_series',
1622
'hist_frame', 'boxplot', 'boxplot_frame', 'boxplot_frame_groupby',

0 commit comments

Comments
 (0)