@@ -178,9 +178,9 @@ For labeled, non-time series data, you may wish to produce a bar plot:
178
178
plt.figure();
179
179
180
180
@savefig bar_plot_ex.png
181
- df.ix[5 ].plot( kind = ' bar' ); plt.axhline(0 , color = ' k' )
181
+ df.ix[5 ].plot. bar( ); plt.axhline(0 , color = ' k' )
182
182
183
- Calling a DataFrame's :meth: `~DataFrame.plot ` method with `` kind='bar' `` produces a multiple
183
+ Calling a DataFrame's :meth: `~DataFrame.plot.bar ` method produces a multiple
184
184
bar plot:
185
185
186
186
.. ipython :: python
@@ -195,7 +195,7 @@ bar plot:
195
195
df2 = pd.DataFrame(np.random.rand(10 , 4 ), columns = [' a' , ' b' , ' c' , ' d' ])
196
196
197
197
@savefig bar_plot_multi_ex.png
198
- df2.plot( kind = ' bar' );
198
+ df2.plot. bar( );
199
199
200
200
To produce a stacked bar plot, pass ``stacked=True ``:
201
201
@@ -208,9 +208,9 @@ To produce a stacked bar plot, pass ``stacked=True``:
208
208
.. ipython :: python
209
209
210
210
@savefig bar_plot_stacked_ex.png
211
- df2.plot( kind = ' bar' , stacked = True );
211
+ df2.plot. bar( stacked = True );
212
212
213
- To get horizontal bar plots, pass `` kind=' barh' `` :
213
+ To get horizontal bar plots, use the `` barh `` method :
214
214
215
215
.. ipython :: python
216
216
:suppress:
@@ -221,16 +221,20 @@ To get horizontal bar plots, pass ``kind='barh'``:
221
221
.. ipython :: python
222
222
223
223
@savefig barh_plot_stacked_ex.png
224
- df2.plot( kind = ' barh' , stacked = True );
224
+ df2.plot. barh( stacked = True );
225
225
226
226
.. _visualization.hist :
227
227
228
228
Histograms
229
229
~~~~~~~~~~
230
230
231
+ .. versionadded :: 0.17.0
232
+
233
+ Histogram can be drawn by using the :meth: `DataFrame.plot.hist ` and :meth: `Series.plot.hist ` methods.
234
+
231
235
.. versionadded :: 0.15.0
232
236
233
- Histogram can be drawn specifying `` kind='hist' `` .
237
+ Histogram can be drawn by using the `` plot( kind='hist') `` method .
234
238
235
239
.. ipython :: python
236
240
@@ -240,7 +244,7 @@ Histogram can be drawn specifying ``kind='hist'``.
240
244
plt.figure();
241
245
242
246
@savefig hist_new.png
243
- df4.plot( kind = ' hist' , alpha = 0.5 )
247
+ df4.plot. hist( alpha = 0.5 )
244
248
245
249
246
250
.. ipython :: python
@@ -255,7 +259,7 @@ Histogram can be stacked by ``stacked=True``. Bin size can be changed by ``bins`
255
259
plt.figure();
256
260
257
261
@savefig hist_new_stacked.png
258
- df4.plot( kind = ' hist' , stacked = True , bins = 20 )
262
+ df4.plot. hist( stacked = True , bins = 20 )
259
263
260
264
.. ipython :: python
261
265
:suppress:
@@ -269,7 +273,7 @@ You can pass other keywords supported by matplotlib ``hist``. For example, horiz
269
273
plt.figure();
270
274
271
275
@savefig hist_new_kwargs.png
272
- df4[' a' ].plot( kind = ' hist' , orientation = ' horizontal' , cumulative = True )
276
+ df4[' a' ].plot. hist( orientation = ' horizontal' , cumulative = True )
273
277
274
278
.. ipython :: python
275
279
:suppress:
@@ -329,8 +333,12 @@ The ``by`` keyword can be specified to plot grouped histograms:
329
333
Box Plots
330
334
~~~~~~~~~
331
335
332
- Boxplot can be drawn calling a ``Series `` and ``DataFrame.plot `` with ``kind='box' ``,
333
- or ``DataFrame.boxplot `` to visualize the distribution of values within each column.
336
+ Boxplot can be drawn calling :meth: `Series.plot.box ` and :meth: `DataFrame.plot.box `,
337
+ or :meth: `DataFrame.boxplot ` to visualize the distribution of values within each column.
338
+
339
+ .. versionadded :: 0.17.0
340
+
341
+ :meth: `DataFrame.plot.box ` and :meth: `Series.plot.box ` can now be used to draw boxplot.
334
342
335
343
.. versionadded :: 0.15.0
336
344
@@ -350,7 +358,7 @@ a uniform random variable on [0,1).
350
358
df = pd.DataFrame(np.random.rand(10 , 5 ), columns = [' A' , ' B' , ' C' , ' D' , ' E' ])
351
359
352
360
@savefig box_plot_new.png
353
- df.plot( kind = ' box' )
361
+ df.plot. box( )
354
362
355
363
Boxplot can be colorized by passing ``color `` keyword. You can pass a ``dict ``
356
364
whose keys are ``boxes ``, ``whiskers ``, ``medians `` and ``caps ``.
@@ -371,7 +379,7 @@ more complicated colorization, you can get each drawn artists by passing
371
379
medians = ' DarkBlue' , caps = ' Gray' )
372
380
373
381
@savefig box_new_colorize.png
374
- df.plot( kind = ' box' , color = color, sym = ' r+' )
382
+ df.plot. box( color = color, sym = ' r+' )
375
383
376
384
.. ipython :: python
377
385
:suppress:
@@ -385,7 +393,7 @@ For example, horizontal and custom-positioned boxplot can be drawn by
385
393
.. ipython :: python
386
394
387
395
@savefig box_new_kwargs.png
388
- df.plot( kind = ' box' , vert = False , positions = [1 , 4 , 5 , 6 , 8 ])
396
+ df.plot. box( vert = False , positions = [1 , 4 , 5 , 6 , 8 ])
389
397
390
398
391
399
See the :meth: `boxplot <matplotlib.axes.Axes.boxplot> ` method and the
@@ -464,7 +472,7 @@ When ``subplots=False`` / ``by`` is ``None``:
464
472
465
473
* if ``return_type `` is ``'dict' ``, a dictionary containing the :class: `matplotlib Lines <matplotlib.lines.Line2D> ` is returned. The keys are "boxes", "caps", "fliers", "medians", and "whiskers".
466
474
This is the default of ``boxplot `` in historical reason.
467
- Note that ``plot( kind= 'box') `` returns ``Axes `` as default as the same as other plots.
475
+ Note that both ``plot.box() `` and `` plot( kind'box') `` return ``Axes `` as default as the same as other plots.
468
476
* if ``return_type `` is ``'axes' ``, a :class: `matplotlib Axes <matplotlib.axes.Axes> ` containing the boxplot is returned.
469
477
* if ``return_type `` is ``'both' `` a namedtuple containging the :class: `matplotlib Axes <matplotlib.axes.Axes> `
470
478
and :class: `matplotlib Lines <matplotlib.lines.Line2D> ` is returned
@@ -514,6 +522,10 @@ Compare to:
514
522
Area Plot
515
523
~~~~~~~~~
516
524
525
+ .. versionadded :: 0.17
526
+
527
+ You can create area plots with :meth: `Series.plot.area ` and :meth: `DataFrame.plot.area `.
528
+
517
529
.. versionadded :: 0.14
518
530
519
531
You can create area plots with ``Series.plot `` and ``DataFrame.plot `` by passing ``kind='area' ``. Area plots are stacked by default. To produce stacked area plot, each column must be either all positive or all negative values.
@@ -531,7 +543,7 @@ When input data contains `NaN`, it will be automatically filled by 0. If you wan
531
543
df = pd.DataFrame(np.random.rand(10 , 4 ), columns = [' a' , ' b' , ' c' , ' d' ])
532
544
533
545
@savefig area_plot_stacked.png
534
- df.plot( kind = ' area' );
546
+ df.plot. area( );
535
547
536
548
To produce an unstacked plot, pass ``stacked=False ``. Alpha value is set to 0.5 unless otherwise specified:
537
549
@@ -544,13 +556,17 @@ To produce an unstacked plot, pass ``stacked=False``. Alpha value is set to 0.5
544
556
.. ipython :: python
545
557
546
558
@savefig area_plot_unstacked.png
547
- df.plot( kind = ' area' , stacked = False );
559
+ df.plot. area( stacked = False );
548
560
549
561
.. _visualization.scatter :
550
562
551
563
Scatter Plot
552
564
~~~~~~~~~~~~
553
565
566
+ .. versionadded :: 0.17.0
567
+
568
+ Histogram can be drawn by using the :meth: `DataFrame.plot.scatter ` and :meth: `Series.plot.scatter ` methods.
569
+
554
570
.. versionadded :: 0.13
555
571
556
572
You can create scatter plots with ``DataFrame.plot `` by passing ``kind='scatter' ``.
@@ -569,17 +585,17 @@ These can be specified by ``x`` and ``y`` keywords each.
569
585
df = pd.DataFrame(np.random.rand(50 , 4 ), columns = [' a' , ' b' , ' c' , ' d' ])
570
586
571
587
@savefig scatter_plot.png
572
- df.plot( kind = ' scatter' , x = ' a' , y = ' b' );
588
+ df.plot. scatter( x = ' a' , y = ' b' );
573
589
574
590
To plot multiple column groups in a single axes, repeat ``plot `` method specifying target ``ax ``.
575
591
It is recommended to specify ``color `` and ``label `` keywords to distinguish each groups.
576
592
577
593
.. ipython :: python
578
594
579
- ax = df.plot( kind = ' scatter' , x = ' a' , y = ' b' ,
595
+ ax = df.plot. scatter( x = ' a' , y = ' b' ,
580
596
color = ' DarkBlue' , label = ' Group 1' );
581
597
@savefig scatter_plot_repeated.png
582
- df.plot( kind = ' scatter' , x = ' c' , y = ' d' ,
598
+ df.plot. scatter( x = ' c' , y = ' d' ,
583
599
color = ' DarkGreen' , label = ' Group 2' , ax = ax);
584
600
585
601
.. ipython :: python
@@ -593,7 +609,7 @@ each point:
593
609
.. ipython :: python
594
610
595
611
@savefig scatter_plot_colored.png
596
- df.plot( kind = ' scatter' , x = ' a' , y = ' b' , c = ' c' , s = 50 );
612
+ df.plot. scatter( x = ' a' , y = ' b' , c = ' c' , s = 50 );
597
613
598
614
599
615
.. ipython :: python
@@ -607,7 +623,7 @@ Below example shows a bubble chart using a dataframe column values as bubble siz
607
623
.. ipython :: python
608
624
609
625
@savefig scatter_plot_bubble.png
610
- df.plot( kind = ' scatter' , x = ' a' , y = ' b' , s = df[' c' ]* 200 );
626
+ df.plot. scatter( x = ' a' , y = ' b' , s = df[' c' ]* 200 );
611
627
612
628
.. ipython :: python
613
629
:suppress:
@@ -622,6 +638,10 @@ See the :meth:`scatter <matplotlib.axes.Axes.scatter>` method and the
622
638
Hexagonal Bin Plot
623
639
~~~~~~~~~~~~~~~~~~
624
640
641
+ .. versionadded :: 0.17.0
642
+
643
+ You can create hexagonal bin plots with :meth: `DataFrame.plot.hexbin `.
644
+
625
645
.. versionadded :: 0.14
626
646
627
647
You can create hexagonal bin plots with :meth: `DataFrame.plot ` and
@@ -641,7 +661,7 @@ too dense to plot each point individually.
641
661
df[' b' ] = df[' b' ] + np.arange(1000 )
642
662
643
663
@savefig hexbin_plot.png
644
- df.plot( kind = ' hexbin' , x = ' a' , y = ' b' , gridsize = 25 )
664
+ df.plot. hexbin( x = ' a' , y = ' b' , gridsize = 25 )
645
665
646
666
647
667
A useful keyword argument is ``gridsize ``; it controls the number of hexagons
@@ -670,7 +690,7 @@ given by column ``z``. The bins are aggregated with numpy's ``max`` function.
670
690
df[' z' ] = np.random.uniform(0 , 3 , 1000 )
671
691
672
692
@savefig hexbin_plot_agg.png
673
- df.plot( kind = ' hexbin' , x = ' a' , y = ' b' , C = ' z' , reduce_C_function = np.max,
693
+ df.plot. hexbin( x = ' a' , y = ' b' , C = ' z' , reduce_C_function = np.max,
674
694
gridsize = 25 )
675
695
676
696
.. ipython :: python
@@ -686,6 +706,10 @@ See the :meth:`hexbin <matplotlib.axes.Axes.hexbin>` method and the
686
706
Pie plot
687
707
~~~~~~~~
688
708
709
+ .. versionadded :: 0.17
710
+
711
+ You can create a pie plot with :meth: `DataFrame.plot.pie ` or :meth: `Series.plot.pie `.
712
+
689
713
.. versionadded :: 0.14
690
714
691
715
You can create a pie plot with :meth: `DataFrame.plot ` or :meth: `Series.plot ` with ``kind='pie' ``.
@@ -703,7 +727,7 @@ A ``ValueError`` will be raised if there are any negative values in your data.
703
727
series = pd.Series(3 * np.random.rand(4 ), index = [' a' , ' b' , ' c' , ' d' ], name = ' series' )
704
728
705
729
@savefig series_pie_plot.png
706
- series.plot( kind = ' pie' , figsize = (6 , 6 ))
730
+ series.plot. pie( figsize = (6 , 6 ))
707
731
708
732
.. ipython :: python
709
733
:suppress:
@@ -730,7 +754,7 @@ A legend will be drawn in each pie plots by default; specify ``legend=False`` to
730
754
df = pd.DataFrame(3 * np.random.rand(4 , 2 ), index = [' a' , ' b' , ' c' , ' d' ], columns = [' x' , ' y' ])
731
755
732
756
@savefig df_pie_plot.png
733
- df.plot( kind = ' pie' , subplots = True , figsize = (8 , 4 ))
757
+ df.plot. pie( subplots = True , figsize = (8 , 4 ))
734
758
735
759
.. ipython :: python
736
760
:suppress:
@@ -757,7 +781,7 @@ Also, other keywords supported by :func:`matplotlib.pyplot.pie` can be used.
757
781
.. ipython :: python
758
782
759
783
@savefig series_pie_plot_options.png
760
- series.plot( kind = ' pie' , labels = [' AA' , ' BB' , ' CC' , ' DD' ], colors = [' r' , ' g' , ' b' , ' c' ],
784
+ series.plot. pie( labels = [' AA' , ' BB' , ' CC' , ' DD' ], colors = [' r' , ' g' , ' b' , ' c' ],
761
785
autopct = ' %.2f ' , fontsize = 20 , figsize = (6 , 6 ))
762
786
763
787
If you pass values whose sum total is less than 1.0, matplotlib draws a semicircle.
@@ -773,7 +797,7 @@ If you pass values whose sum total is less than 1.0, matplotlib draws a semicirc
773
797
series = pd.Series([0.1 ] * 4 , index = [' a' , ' b' , ' c' , ' d' ], name = ' series2' )
774
798
775
799
@savefig series_pie_plot_semi.png
776
- series.plot( kind = ' pie' , figsize = (6 , 6 ))
800
+ series.plot. pie( figsize = (6 , 6 ))
777
801
778
802
See the `matplotlib pie documentation <http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pie >`__ for more.
779
803
@@ -861,6 +885,10 @@ You can create a scatter plot matrix using the
861
885
Density Plot
862
886
~~~~~~~~~~~~
863
887
888
+ .. versionadded :: 0.17.0
889
+
890
+ You can create density plots using the :meth: `Series.plot.kde ` and :meth: `DataFrame.plot.kde ` methods.
891
+
864
892
.. versionadded :: 0.8.0
865
893
866
894
You can create density plots using the Series/DataFrame.plot and
@@ -877,7 +905,7 @@ setting ``kind='kde'``:
877
905
ser = pd.Series(np.random.randn(1000 ))
878
906
879
907
@savefig kde_plot.png
880
- ser.plot( kind = ' kde' )
908
+ ser.plot. kde( )
881
909
882
910
.. ipython :: python
883
911
:suppress:
@@ -1392,7 +1420,7 @@ Here is an example of one way to easily plot group means with standard deviation
1392
1420
# Plot
1393
1421
fig, ax = plt.subplots()
1394
1422
@savefig errorbar_example.png
1395
- means.plot(yerr = errors, ax = ax, kind = ' bar ' )
1423
+ means.plot.bar (yerr = errors, ax = ax)
1396
1424
1397
1425
.. ipython :: python
1398
1426
:suppress:
@@ -1532,7 +1560,7 @@ Colormaps can also be used other plot types, like bar charts:
1532
1560
plt.figure()
1533
1561
1534
1562
@savefig greens.png
1535
- dd.plot( kind = ' bar' , colormap = ' Greens' )
1563
+ dd.plot. bar( colormap = ' Greens' )
1536
1564
1537
1565
.. ipython :: python
1538
1566
:suppress:
0 commit comments