Skip to content

Commit f1f9744

Browse files
committed
CLN: move plotting funcs to pd.plotting
1 parent b895968 commit f1f9744

24 files changed

+5481
-5397
lines changed

doc/source/visualization.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ You can also create these other plots using the methods ``DataFrame.plot.<kind>`
152152
In addition to these ``kind`` s, there are the :ref:`DataFrame.hist() <visualization.hist>`,
153153
and :ref:`DataFrame.boxplot() <visualization.box>` methods, which use a separate interface.
154154

155-
Finally, there are several :ref:`plotting functions <visualization.tools>` in ``pandas.tools.plotting``
155+
Finally, there are several :ref:`plotting functions <visualization.tools>` in ``pandas.plotting``
156156
that take a :class:`Series` or :class:`DataFrame` as an argument. These
157157
include
158158

@@ -823,7 +823,7 @@ before plotting.
823823
Plotting Tools
824824
--------------
825825

826-
These functions can be imported from ``pandas.tools.plotting``
826+
These functions can be imported from ``pandas.plotting``
827827
and take a :class:`Series` or :class:`DataFrame` as an argument.
828828

829829
.. _visualization.scatter_matrix:
@@ -834,7 +834,7 @@ Scatter Matrix Plot
834834
.. versionadded:: 0.7.3
835835

836836
You can create a scatter plot matrix using the
837-
``scatter_matrix`` method in ``pandas.tools.plotting``:
837+
``scatter_matrix`` method in ``pandas.plotting``:
838838

839839
.. ipython:: python
840840
:suppress:
@@ -843,7 +843,7 @@ You can create a scatter plot matrix using the
843843
844844
.. ipython:: python
845845
846-
from pandas.tools.plotting import scatter_matrix
846+
from pandas.plotting import scatter_matrix
847847
df = pd.DataFrame(np.random.randn(1000, 4), columns=['a', 'b', 'c', 'd'])
848848
849849
@savefig scatter_matrix_kde.png
@@ -896,7 +896,7 @@ of the same class will usually be closer together and form larger structures.
896896

897897
.. ipython:: python
898898
899-
from pandas.tools.plotting import andrews_curves
899+
from pandas.plotting import andrews_curves
900900
901901
data = pd.read_csv('data/iris.data')
902902
@@ -918,7 +918,7 @@ represents one data point. Points that tend to cluster will appear closer togeth
918918

919919
.. ipython:: python
920920
921-
from pandas.tools.plotting import parallel_coordinates
921+
from pandas.plotting import parallel_coordinates
922922
923923
data = pd.read_csv('data/iris.data')
924924
@@ -948,7 +948,7 @@ implies that the underlying data are not random.
948948
949949
.. ipython:: python
950950
951-
from pandas.tools.plotting import lag_plot
951+
from pandas.plotting import lag_plot
952952
953953
plt.figure()
954954
@@ -983,7 +983,7 @@ confidence band.
983983
984984
.. ipython:: python
985985
986-
from pandas.tools.plotting import autocorrelation_plot
986+
from pandas.plotting import autocorrelation_plot
987987
988988
plt.figure()
989989
@@ -1016,7 +1016,7 @@ are what constitutes the bootstrap plot.
10161016
10171017
.. ipython:: python
10181018
1019-
from pandas.tools.plotting import bootstrap_plot
1019+
from pandas.plotting import bootstrap_plot
10201020
10211021
data = pd.Series(np.random.rand(1000))
10221022
@@ -1048,7 +1048,7 @@ be colored differently.
10481048

10491049
.. ipython:: python
10501050
1051-
from pandas.tools.plotting import radviz
1051+
from pandas.plotting import radviz
10521052
10531053
data = pd.read_csv('data/iris.data')
10541054
@@ -1438,11 +1438,11 @@ Also, you can pass different :class:`DataFrame` or :class:`Series` for ``table``
14381438
14391439
plt.close('all')
14401440
1441-
Finally, there is a helper function ``pandas.tools.plotting.table`` to create a table from :class:`DataFrame` and :class:`Series`, and add it to an ``matplotlib.Axes``. This function can accept keywords which matplotlib table has.
1441+
Finally, there is a helper function ``pandas.plotting.table`` to create a table from :class:`DataFrame` and :class:`Series`, and add it to an ``matplotlib.Axes``. This function can accept keywords which matplotlib table has.
14421442

14431443
.. ipython:: python
14441444
1445-
from pandas.tools.plotting import table
1445+
from pandas.plotting import table
14461446
fig, ax = plt.subplots(1, 1)
14471447
14481448
table(ax, np.round(df.describe(), 2),

pandas/api/tests/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class TestPDApi(Base, tm.TestCase):
3636
lib = ['api', 'compat', 'computation', 'core',
3737
'indexes', 'formats', 'pandas',
3838
'test', 'tools', 'tseries',
39-
'types', 'util', 'options', 'io']
39+
'types', 'util', 'options', 'io', 'plotting']
4040

4141
# top-level packages that are c-imports, should rename to _*
4242
# to avoid naming conflicts

pandas/core/config_init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def mpl_style_cb(key):
257257
stacklevel=5)
258258

259259
import sys
260-
from pandas.tools.plotting import mpl_stylesheet
260+
from pandas.plotting.style import mpl_stylesheet
261261
global style_backup
262262

263263
val = cf.get_option(key)

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
import pandas.core.ops as ops
9191
import pandas.formats.format as fmt
9292
from pandas.formats.printing import pprint_thing
93-
import pandas.tools.plotting as gfx
93+
import pandas.plotting.plotting as gfx
9494

9595
import pandas.lib as lib
9696
import pandas.algos as _algos
@@ -5717,7 +5717,7 @@ def _put_str(s, space):
57175717
@Appender(_shared_docs['boxplot'] % _shared_doc_kwargs)
57185718
def boxplot(self, column=None, by=None, ax=None, fontsize=None, rot=0,
57195719
grid=True, figsize=None, layout=None, return_type=None, **kwds):
5720-
import pandas.tools.plotting as plots
5720+
import pandas.plotting as plots
57215721
import matplotlib.pyplot as plt
57225722
ax = plots.boxplot(self, column=column, by=by, ax=ax, fontsize=fontsize,
57235723
grid=grid, rot=rot, figsize=figsize, layout=layout,

pandas/core/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3900,7 +3900,7 @@ def count(self):
39003900
return self._wrap_agged_blocks(data.items, list(blk))
39013901

39023902

3903-
from pandas.tools.plotting import boxplot_frame_groupby # noqa
3903+
from pandas.plotting.plotting import boxplot_frame_groupby # noqa
39043904
DataFrameGroupBy.boxplot = boxplot_frame_groupby
39053905

39063906

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2992,7 +2992,7 @@ def __init__(self, *args, **kwargs):
29922992
# ----------------------------------------------------------------------
29932993
# Add plotting methods to Series
29942994

2995-
import pandas.tools.plotting as _gfx # noqa
2995+
import pandas.plotting.plotting as _gfx # noqa
29962996

29972997
Series.plot = base.AccessorProperty(_gfx.SeriesPlotMethods,
29982998
_gfx.SeriesPlotMethods)

pandas/plotting/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from pandas.plotting.api import * # noqa

pandas/plotting/api.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
Plotting api
3+
"""
4+
5+
# flake8: noqa
6+
7+
try: # mpl optional
8+
from pandas.plotting import converter as conv
9+
conv.register() # needs to override so set_xlim works with str/number
10+
except ImportError:
11+
pass
12+
13+
from pandas.plotting.misc import (scatter_matrix, radviz,
14+
andrews_curves, bootstrap_plot,
15+
parallel_coordinates, lag_plot,
16+
autocorrelation_plot)
17+
from pandas.plotting.plotting import (boxplot, scatter_plot, grouped_hist,
18+
hist_frame, hist_series)
19+
from pandas.plotting.style import plot_params
20+
from pandas.plotting.tools import table

pandas/plotting/compat.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# being a bit too dynamic
2+
# pylint: disable=E1101
3+
from __future__ import division
4+
5+
from distutils.version import LooseVersion
6+
7+
8+
def _mpl_le_1_2_1():
9+
try:
10+
import matplotlib as mpl
11+
return (str(mpl.__version__) <= LooseVersion('1.2.1') and
12+
str(mpl.__version__)[0] != '0')
13+
except ImportError:
14+
return False
15+
16+
17+
def _mpl_ge_1_3_1():
18+
try:
19+
import matplotlib
20+
# The or v[0] == '0' is because their versioneer is
21+
# messed up on dev
22+
return (matplotlib.__version__ >= LooseVersion('1.3.1') or
23+
matplotlib.__version__[0] == '0')
24+
except ImportError:
25+
return False
26+
27+
28+
def _mpl_ge_1_4_0():
29+
try:
30+
import matplotlib
31+
return (matplotlib.__version__ >= LooseVersion('1.4') or
32+
matplotlib.__version__[0] == '0')
33+
except ImportError:
34+
return False
35+
36+
37+
def _mpl_ge_1_5_0():
38+
try:
39+
import matplotlib
40+
return (matplotlib.__version__ >= LooseVersion('1.5') or
41+
matplotlib.__version__[0] == '0')
42+
except ImportError:
43+
return False
44+
45+
46+
def _mpl_ge_2_0_0():
47+
try:
48+
import matplotlib
49+
return matplotlib.__version__ >= LooseVersion('2.0')
50+
except ImportError:
51+
return False

0 commit comments

Comments
 (0)