Skip to content

Commit c6452b3

Browse files
also move plot_params
1 parent a1f272a commit c6452b3

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

doc/source/visualization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,14 +1228,14 @@ Using the ``x_compat`` parameter, you can suppress this behavior:
12281228
plt.close('all')
12291229
12301230
If you have more than one plot that needs to be suppressed, the ``use`` method
1231-
in ``pandas.plot_params`` can be used in a `with statement`:
1231+
in ``pandas.plotting.plot_params`` can be used in a `with statement`:
12321232

12331233
.. ipython:: python
12341234
12351235
plt.figure()
12361236
12371237
@savefig ser_plot_suppress_context.png
1238-
with pd.plot_params.use('x_compat', True):
1238+
with pd.plotting.plot_params.use('x_compat', True):
12391239
df.A.plot(color='r')
12401240
df.B.plot(color='g')
12411241
df.C.plot(color='b')

doc/source/whatsnew/v0.20.0.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,11 @@ Using ``.iloc``. Here we will get the location of the 'A' column, then use *posi
563563
Deprecate .plotting
564564
^^^^^^^^^^^^^^^^^^^
565565

566-
``pandas.tools.plotting`` module has been deprecated, moving directory under the
567-
top namespace ``pandas.plotting``. All the public plotting functions should be available
566+
The ``pandas.tools.plotting`` module has been deprecated, in favor of the top level ``pandas.plotting`` module. All the public plotting functions are now available
568567
from ``pandas.plotting``.
569568

570-
Also, ``scatter_matrix`` function imported directly under ``pandas`` namespace is also deprecated.
571-
Users shoud use ``pandas.plotting.scatter_matrix`` instead.
569+
Further, the top-level ``pandas.scatter_matrix`` and ``pandas.plot_params`` are also deprecated.
570+
Users can import these from ``pandas.plotting`` as well.
572571

573572
Previous script:
574573

pandas/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
merge_ordered, merge_asof)
5151
from pandas.tools.pivot import pivot_table, crosstab
5252

53-
# deprecate tools.plotting, and scatter_matrix on the top namespace
53+
# deprecate tools.plotting, plot_params and scatter_matrix on the top namespace
5454
import pandas.tools.plotting
55-
from pandas.plotting import plot_params
55+
plot_params = pandas.plotting.style._Options(deprecated=True)
5656
# do not import deprecate to top namespace
5757
scatter_matrix = pandas.util.decorators.deprecate(
5858
'pandas.scatter_matrix', pandas.plotting.scatter_matrix,

pandas/plotting/style.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,26 @@ class _Options(dict):
179179
_ALIASES = {'x_compat': 'xaxis.compat'}
180180
_DEFAULT_KEYS = ['xaxis.compat']
181181

182-
def __init__(self):
183-
self['xaxis.compat'] = False
182+
def __init__(self, deprecated=False):
183+
self._deprecated = deprecated
184+
# self['xaxis.compat'] = False
185+
super(_Options, self).__setitem__('xaxis.compat', False)
186+
187+
def _warn_if_deprecated(self):
188+
if self._deprecated:
189+
warnings.warn("'pandas.plot_params' is deprecated. Use "
190+
"'pandas.plotting.plot_params' instead",
191+
FutureWarning, stacklevel=3)
184192

185193
def __getitem__(self, key):
194+
self._warn_if_deprecated()
186195
key = self._get_canonical_key(key)
187196
if key not in self:
188197
raise ValueError('%s is not a valid pandas plotting option' % key)
189198
return super(_Options, self).__getitem__(key)
190199

191200
def __setitem__(self, key, value):
201+
self._warn_if_deprecated()
192202
key = self._get_canonical_key(key)
193203
return super(_Options, self).__setitem__(key, value)
194204

@@ -210,6 +220,7 @@ def reset(self):
210220
-------
211221
None
212222
"""
223+
self._warn_if_deprecated()
213224
self.__init__()
214225

215226
def _get_canonical_key(self, key):
@@ -221,6 +232,7 @@ def use(self, key, value):
221232
Temporarily set a parameter value using the with statement.
222233
Aliasing allowed.
223234
"""
235+
self._warn_if_deprecated()
224236
old_value = self[key]
225237
try:
226238
self[key] = value

pandas/tests/api/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class TestPDApi(Base, tm.TestCase):
6969
'melt', 'notnull', 'offsets',
7070
'merge', 'merge_ordered', 'merge_asof',
7171
'period_range',
72-
'pivot', 'pivot_table', 'plot_params', 'qcut',
72+
'pivot', 'pivot_table', 'qcut',
7373
'scatter_matrix',
7474
'show_versions', 'timedelta_range', 'unique',
7575
'value_counts', 'wide_to_long']
@@ -103,7 +103,7 @@ class TestPDApi(Base, tm.TestCase):
103103
'rolling_median', 'rolling_min', 'rolling_quantile',
104104
'rolling_skew', 'rolling_std', 'rolling_sum',
105105
'rolling_var', 'rolling_window', 'ordered_merge',
106-
'pnow', 'match', 'groupby', 'get_store']
106+
'pnow', 'match', 'groupby', 'get_store', 'plot_params']
107107

108108
def test_api(self):
109109

0 commit comments

Comments
 (0)