@@ -26,7 +26,7 @@ libraries that go beyond the basics documented here.
26
26
Basic Plotting: ``plot ``
27
27
------------------------
28
28
29
- We will demonstrate the basics, see the :ref: `cookbook<cookbook.plotting> ` for
29
+ We will demonstrate the basics, see the :ref: `cookbook<cookbook.plotting> ` for
30
30
some advanced strategies.
31
31
32
32
The ``plot `` method on Series and DataFrame is just a simple wrapper around
@@ -87,7 +87,7 @@ You can plot one column versus another using the `x` and `y` keywords in
87
87
88
88
.. note ::
89
89
90
- For more formatting and styling options, see
90
+ For more formatting and styling options, see
91
91
:ref: `formatting <visualization.formatting >` below.
92
92
93
93
.. ipython :: python
@@ -129,7 +129,7 @@ You can also create these other plots using the methods ``DataFrame.plot.<kind>`
129
129
130
130
In [14]: df = pd.DataFrame()
131
131
132
- In [15]: df.plot.<TAB>
132
+ In [15]: df.plot.<TAB> # noqa: E225, E999
133
133
df.plot.area df.plot.barh df.plot.density df.plot.hist df.plot.line df.plot.scatter
134
134
df.plot.bar df.plot.box df.plot.hexbin df.plot.kde df.plot.pie
135
135
@@ -163,7 +163,8 @@ For labeled, non-time series data, you may wish to produce a bar plot:
163
163
plt.figure();
164
164
165
165
@savefig bar_plot_ex.png
166
- df.iloc[5 ].plot.bar(); plt.axhline(0 , color = ' k' )
166
+ df.iloc[5 ].plot.bar()
167
+ plt.axhline(0 , color = ' k' );
167
168
168
169
Calling a DataFrame's :meth: `plot.bar() <DataFrame.plot.bar> ` method produces a multiple
169
170
bar plot:
@@ -231,7 +232,7 @@ Histograms can be drawn by using the :meth:`DataFrame.plot.hist` and :meth:`Seri
231
232
232
233
plt.close(' all' )
233
234
234
- A histogram can be stacked using ``stacked=True ``. Bin size can be changed
235
+ A histogram can be stacked using ``stacked=True ``. Bin size can be changed
235
236
using the ``bins `` keyword.
236
237
237
238
.. ipython :: python
@@ -246,8 +247,8 @@ using the ``bins`` keyword.
246
247
247
248
plt.close(' all' )
248
249
249
- You can pass other keywords supported by matplotlib ``hist ``. For example,
250
- horizontal and cumulative histograms can be drawn by
250
+ You can pass other keywords supported by matplotlib ``hist ``. For example,
251
+ horizontal and cumulative histograms can be drawn by
251
252
``orientation='horizontal' `` and ``cumulative=True ``.
252
253
253
254
.. ipython :: python
@@ -477,7 +478,7 @@ keyword, will affect the output type as well:
477
478
478
479
plt.close(' all' )
479
480
480
- The subplots above are split by the numeric columns first, then the value of
481
+ The subplots above are split by the numeric columns first, then the value of
481
482
the ``g `` column. Below the subplots are first split by the value of ``g ``,
482
483
then by the numeric columns.
483
484
@@ -579,8 +580,8 @@ each point:
579
580
580
581
plt.close(' all' )
581
582
582
- You can pass other keywords supported by matplotlib
583
- :meth: `scatter <matplotlib.axes.Axes.scatter> `. The example below shows a
583
+ You can pass other keywords supported by matplotlib
584
+ :meth: `scatter <matplotlib.axes.Axes.scatter> `. The example below shows a
584
585
bubble chart using a column of the ``DataFrame `` as the bubble size.
585
586
586
587
.. ipython :: python
@@ -684,15 +685,15 @@ A ``ValueError`` will be raised if there are any negative values in your data.
684
685
685
686
plt.close(' all' )
686
687
687
- For pie plots it's best to use square figures, i.e. a figure aspect ratio 1.
688
- You can create the figure with equal width and height, or force the aspect ratio
689
- to be equal after plotting by calling ``ax.set_aspect('equal') `` on the returned
688
+ For pie plots it's best to use square figures, i.e. a figure aspect ratio 1.
689
+ You can create the figure with equal width and height, or force the aspect ratio
690
+ to be equal after plotting by calling ``ax.set_aspect('equal') `` on the returned
690
691
``axes `` object.
691
692
692
- Note that pie plot with :class: `DataFrame ` requires that you either specify a
693
- target column by the ``y `` argument or ``subplots=True ``. When ``y `` is
694
- specified, pie plot of selected column will be drawn. If ``subplots=True `` is
695
- specified, pie plots for each column are drawn as subplots. A legend will be
693
+ Note that pie plot with :class: `DataFrame ` requires that you either specify a
694
+ target column by the ``y `` argument or ``subplots=True ``. When ``y `` is
695
+ specified, pie plot of selected column will be drawn. If ``subplots=True `` is
696
+ specified, pie plots for each column are drawn as subplots. A legend will be
696
697
drawn in each pie plots by default; specify ``legend=False `` to hide it.
697
698
698
699
.. ipython :: python
@@ -918,7 +919,7 @@ Lag Plot
918
919
Lag plots are used to check if a data set or time series is random. Random
919
920
data should not exhibit any structure in the lag plot. Non-random structure
920
921
implies that the underlying data are not random. The ``lag `` argument may
921
- be passed, and when ``lag=1 `` the plot is essentially ``data[:-1] `` vs.
922
+ be passed, and when ``lag=1 `` the plot is essentially ``data[:-1] `` vs.
922
923
``data[1:] ``.
923
924
924
925
.. ipython :: python
@@ -954,7 +955,7 @@ If time series is random, such autocorrelations should be near zero for any and
954
955
all time-lag separations. If time series is non-random then one or more of the
955
956
autocorrelations will be significantly non-zero. The horizontal lines displayed
956
957
in the plot correspond to 95% and 99% confidence bands. The dashed line is 99%
957
- confidence band. See the
958
+ confidence band. See the
958
959
`Wikipedia entry <https://en.wikipedia.org/wiki/Correlogram >`__ for more about
959
960
autocorrelation plots.
960
961
@@ -1446,9 +1447,9 @@ Plotting with matplotlib table is now supported in :meth:`DataFrame.plot` and :
1446
1447
1447
1448
plt.close(' all' )
1448
1449
1449
- Also, you can pass a different :class: `DataFrame ` or :class: `Series ` to the
1450
- ``table `` keyword. The data will be drawn as displayed in print method
1451
- (not transposed automatically). If required, it should be transposed manually
1450
+ Also, you can pass a different :class: `DataFrame ` or :class: `Series ` to the
1451
+ ``table `` keyword. The data will be drawn as displayed in print method
1452
+ (not transposed automatically). If required, it should be transposed manually
1452
1453
as seen in the example below.
1453
1454
1454
1455
.. ipython :: python
@@ -1463,9 +1464,9 @@ as seen in the example below.
1463
1464
1464
1465
plt.close(' all' )
1465
1466
1466
- There also exists a helper function ``pandas.plotting.table ``, which creates a
1467
- table from :class: `DataFrame ` or :class: `Series `, and adds it to an
1468
- ``matplotlib.Axes `` instance. This function can accept keywords which the
1467
+ There also exists a helper function ``pandas.plotting.table ``, which creates a
1468
+ table from :class: `DataFrame ` or :class: `Series `, and adds it to an
1469
+ ``matplotlib.Axes `` instance. This function can accept keywords which the
1469
1470
matplotlib `table <http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.table >`__ has.
1470
1471
1471
1472
.. ipython :: python
@@ -1597,8 +1598,8 @@ Plotting directly with matplotlib
1597
1598
1598
1599
In some situations it may still be preferable or necessary to prepare plots
1599
1600
directly with matplotlib, for instance when a certain type of plot or
1600
- customization is not (yet) supported by pandas. ``Series `` and ``DataFrame ``
1601
- objects behave like arrays and can therefore be passed directly to
1601
+ customization is not (yet) supported by pandas. ``Series `` and ``DataFrame ``
1602
+ objects behave like arrays and can therefore be passed directly to
1602
1603
matplotlib functions without explicit casts.
1603
1604
1604
1605
pandas also automatically registers formatters and locators that recognize date
0 commit comments