You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#9124
This PR adds plotting sub-methods like `df.plot.scatter()` as an alternative
to using `df.plot(kind='scatter')`.
I've added meaningful function signatures and documentation for a few of these
methods, but I would greatly appreciate help to fill in the rest -- this is a
lot of documentation to write! The entire point of this PR, of course, is to
have better introspection and docstrings.
Copy file name to clipboardExpand all lines: doc/source/visualization.rst
+16-2
Original file line number
Diff line number
Diff line change
@@ -121,8 +121,9 @@ You can plot one column versus another using the `x` and `y` keywords in
121
121
Other Plots
122
122
-----------
123
123
124
-
The ``kind`` keyword argument of :meth:`~DataFrame.plot` accepts
125
-
a handful of values for plots other than the default Line plot.
124
+
Plotting methods allow for a handful of plot styles other than the
125
+
default Line plot. These methods can be provided as the ``kind``
126
+
keyword argument to :meth:`~DataFrame.plot`.
126
127
These include:
127
128
128
129
* :ref:`'bar' <visualization.barplot>` or :ref:`'barh' <visualization.barplot>` for bar plots
@@ -134,6 +135,19 @@ These include:
134
135
* :ref:`'hexbin' <visualization.hexbin>` for hexagonal bin plots
135
136
* :ref:`'pie' <visualization.pie>` for pie plots
136
137
138
+
.. versionadded:: 0.17
139
+
140
+
You can also create these other plots using the methods ``DataFrame.plot.<kind>`` instead of providing the ``kind`` keyword argument. This makes it easier to discover plot methods and the specific arguments they use:
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.17.0.txt
+30-1
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ users upgrade to this version.
29
29
Highlights include:
30
30
31
31
- Release the Global Interpreter Lock (GIL) on some cython operations, see :ref:`here <whatsnew_0170.gil>`
32
+
- Plotting methods are now available as attributes of the ``.plot`` accessor, see :ref:`here <whatsnew_0170.plot>`
32
33
- The sorting API has been revamped to remove some long-time inconsistencies, see :ref:`here <whatsnew_0170.api_breaking.sorting>`
33
34
- Support for a ``datetime64[ns]`` with timezones as a first-class dtype, see :ref:`here <whatsnew_0170.tz>`
34
35
- The default for ``to_datetime`` will now be to ``raise`` when presented with unparseable formats,
@@ -116,6 +117,35 @@ Releasing of the GIL could benefit an application that uses threads for user int
116
117
.. _dask: https://dask.readthedocs.org/en/latest/
117
118
.. _QT: https://wiki.python.org/moin/PyQt
118
119
120
+
.. _whatsnew_0170.plot:
121
+
122
+
Plot submethods
123
+
^^^^^^^^^^^^^^^
124
+
125
+
The Series and DataFrame ``.plot()`` method allows for customizing :ref:`plot types<visualization.other>` by supplying the ``kind`` keyword arguments. Unfortunately, many of these kinds of plots use different required and optional keyword arguments, which makes it difficult to discover what any given plot kind uses out of the dozens of possible arguments.
126
+
127
+
To alleviate this issue, we have added a new, optional plotting interface, which exposes each kind of plot as a method of the ``.plot`` attribute. Instead of writing ``series.plot(kind=<kind>, ...)``, you can now also use ``series.plot.<kind>(...)``:
128
+
129
+
.. ipython::
130
+
:verbatim:
131
+
132
+
In [13]: df = pd.DataFrame(np.random.rand(10, 2), columns=['a', 'b'])
133
+
134
+
In [14]: df.plot.bar()
135
+
136
+
.. image:: _static/whatsnew_plot_submethods.png
137
+
138
+
As a result of this change, these methods are now all discoverable via tab-completion:
Each method signature only includes relevant arguments. Currently, these are limited to required arguments, but in the future these will include optional arguments, as well. For an overview, see the new :ref:`api.dataframe.plotting` API documentation.
148
+
119
149
.. _whatsnew_0170.strftime:
120
150
121
151
Support strftime for Datetimelikes
@@ -251,7 +281,6 @@ has been changed to make this keyword unnecessary - the change is shown below.
251
281
Excel files saved in version 0.16.2 or prior that had index names will still able to be read in,
252
282
but the ``has_index_names`` argument must specified to ``True``.
0 commit comments