Skip to content

Commit b2eebed

Browse files
committed
CLN: move plotting funcs to pd.plotting
1 parent 4488f18 commit b2eebed

24 files changed

+5443
-5354
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

@@ -822,7 +822,7 @@ before plotting.
822822
Plotting Tools
823823
--------------
824824

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

828828
.. _visualization.scatter_matrix:
@@ -833,7 +833,7 @@ Scatter Matrix Plot
833833
.. versionadded:: 0.7.3
834834

835835
You can create a scatter plot matrix using the
836-
``scatter_matrix`` method in ``pandas.tools.plotting``:
836+
``scatter_matrix`` method in ``pandas.plotting``:
837837

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

896896
.. ipython:: python
897897
898-
from pandas.tools.plotting import andrews_curves
898+
from pandas.plotting import andrews_curves
899899
900900
data = pd.read_csv('data/iris.data')
901901
@@ -917,7 +917,7 @@ represents one data point. Points that tend to cluster will appear closer togeth
917917

918918
.. ipython:: python
919919
920-
from pandas.tools.plotting import parallel_coordinates
920+
from pandas.plotting import parallel_coordinates
921921
922922
data = pd.read_csv('data/iris.data')
923923
@@ -947,7 +947,7 @@ implies that the underlying data are not random.
947947
948948
.. ipython:: python
949949
950-
from pandas.tools.plotting import lag_plot
950+
from pandas.plotting import lag_plot
951951
952952
plt.figure()
953953
@@ -982,7 +982,7 @@ confidence band.
982982
983983
.. ipython:: python
984984
985-
from pandas.tools.plotting import autocorrelation_plot
985+
from pandas.plotting import autocorrelation_plot
986986
987987
plt.figure()
988988
@@ -1015,7 +1015,7 @@ are what constitutes the bootstrap plot.
10151015
10161016
.. ipython:: python
10171017
1018-
from pandas.tools.plotting import bootstrap_plot
1018+
from pandas.plotting import bootstrap_plot
10191019
10201020
data = pd.Series(np.random.rand(1000))
10211021
@@ -1047,7 +1047,7 @@ be colored differently.
10471047

10481048
.. ipython:: python
10491049
1050-
from pandas.tools.plotting import radviz
1050+
from pandas.plotting import radviz
10511051
10521052
data = pd.read_csv('data/iris.data')
10531053
@@ -1437,11 +1437,11 @@ Also, you can pass different :class:`DataFrame` or :class:`Series` for ``table``
14371437
14381438
plt.close('all')
14391439
1440-
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.
1440+
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.
14411441

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

pandas/api/tests/test_api.py

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

3939
# top-level packages that are c-imports, should rename to _*
4040
# 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
@@ -5721,7 +5721,7 @@ def _put_str(s, space):
57215721
@Appender(_shared_docs['boxplot'] % _shared_doc_kwargs)
57225722
def boxplot(self, column=None, by=None, ax=None, fontsize=None, rot=0,
57235723
grid=True, figsize=None, layout=None, return_type=None, **kwds):
5724-
import pandas.tools.plotting as plots
5724+
import pandas.plotting as plots
57255725
import matplotlib.pyplot as plt
57265726
ax = plots.boxplot(self, column=column, by=by, ax=ax, fontsize=fontsize,
57275727
grid=grid, rot=rot, figsize=figsize, layout=layout,

pandas/core/groupby.py

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

38673867

3868-
from pandas.tools.plotting import boxplot_frame_groupby # noqa
3868+
from pandas.plotting.plotting import boxplot_frame_groupby # noqa
38693869
DataFrameGroupBy.boxplot = boxplot_frame_groupby
38703870

38713871

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2943,7 +2943,7 @@ def __init__(self, *args, **kwargs):
29432943
# ----------------------------------------------------------------------
29442944
# Add plotting methods to Series
29452945

2946-
import pandas.tools.plotting as _gfx # noqa
2946+
import pandas.plotting.plotting as _gfx # noqa
29472947

29482948
Series.plot = base.AccessorProperty(_gfx.SeriesPlotMethods,
29492949
_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)