@@ -64,7 +64,7 @@ On DataFrame, :meth:`~DataFrame.plot` is a convenience to plot all of the column
64
64
65
65
plt.figure();
66
66
@savefig frame_plot_basic.png
67
- df.plot()
67
+ df.plot();
68
68
69
69
You can plot one column versus another using the ``x `` and ``y `` keywords in
70
70
:meth: `~DataFrame.plot `:
@@ -119,7 +119,7 @@ For example, a bar plot can be created the following way:
119
119
plt.figure();
120
120
121
121
@savefig bar_plot_ex.png
122
- df.iloc[5 ].plot(kind = " bar" )
122
+ df.iloc[5 ].plot(kind = " bar" );
123
123
124
124
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:
125
125
@@ -180,7 +180,7 @@ bar plot:
180
180
df2 = pd.DataFrame(np.random.rand(10 , 4 ), columns = [" a" , " b" , " c" , " d" ])
181
181
182
182
@savefig bar_plot_multi_ex.png
183
- df2.plot.bar()
183
+ df2.plot.bar();
184
184
185
185
To produce a stacked bar plot, pass ``stacked=True ``:
186
186
@@ -193,7 +193,7 @@ To produce a stacked bar plot, pass ``stacked=True``:
193
193
.. ipython :: python
194
194
195
195
@savefig bar_plot_stacked_ex.png
196
- df2.plot.bar(stacked = True )
196
+ df2.plot.bar(stacked = True );
197
197
198
198
To get horizontal bar plots, use the ``barh `` method:
199
199
@@ -206,7 +206,7 @@ To get horizontal bar plots, use the ``barh`` method:
206
206
.. ipython :: python
207
207
208
208
@savefig barh_plot_stacked_ex.png
209
- df2.plot.barh(stacked = True )
209
+ df2.plot.barh(stacked = True );
210
210
211
211
.. _visualization.hist :
212
212
@@ -414,7 +414,7 @@ groupings. For instance,
414
414
df = pd.DataFrame(np.random.rand(10 , 2 ), columns = [" Col1" , " Col2" ])
415
415
df[" X" ] = pd.Series([" A" , " A" , " A" , " A" , " A" , " B" , " B" , " B" , " B" , " B" ])
416
416
417
- plt.figure()
417
+ plt.figure();
418
418
419
419
@savefig box_plot_ex2.png
420
420
bp = df.boxplot(by = " X" )
@@ -518,7 +518,7 @@ When input data contains ``NaN``, it will be automatically filled by 0. If you w
518
518
df = pd.DataFrame(np.random.rand(10 , 4 ), columns = [" a" , " b" , " c" , " d" ])
519
519
520
520
@savefig area_plot_stacked.png
521
- df.plot.area()
521
+ df.plot.area();
522
522
523
523
To produce an unstacked plot, pass ``stacked=False ``. Alpha value is set to 0.5 unless otherwise specified:
524
524
@@ -531,7 +531,7 @@ To produce an unstacked plot, pass ``stacked=False``. Alpha value is set to 0.5
531
531
.. ipython :: python
532
532
533
533
@savefig area_plot_unstacked.png
534
- df.plot.area(stacked = False )
534
+ df.plot.area(stacked = False );
535
535
536
536
.. _visualization.scatter :
537
537
@@ -554,7 +554,7 @@ These can be specified by the ``x`` and ``y`` keywords.
554
554
df = pd.DataFrame(np.random.rand(50 , 4 ), columns = [" a" , " b" , " c" , " d" ])
555
555
556
556
@savefig scatter_plot.png
557
- df.plot.scatter(x = " a" , y = " b" )
557
+ df.plot.scatter(x = " a" , y = " b" );
558
558
559
559
To plot multiple column groups in a single axes, repeat ``plot `` method specifying target ``ax ``.
560
560
It is recommended to specify ``color `` and ``label `` keywords to distinguish each groups.
@@ -563,7 +563,7 @@ It is recommended to specify ``color`` and ``label`` keywords to distinguish eac
563
563
564
564
ax = df.plot.scatter(x = " a" , y = " b" , color = " DarkBlue" , label = " Group 1" )
565
565
@savefig scatter_plot_repeated.png
566
- df.plot.scatter(x = " c" , y = " d" , color = " DarkGreen" , label = " Group 2" , ax = ax)
566
+ df.plot.scatter(x = " c" , y = " d" , color = " DarkGreen" , label = " Group 2" , ax = ax);
567
567
568
568
.. ipython :: python
569
569
:suppress:
@@ -576,7 +576,7 @@ each point:
576
576
.. ipython :: python
577
577
578
578
@savefig scatter_plot_colored.png
579
- df.plot.scatter(x = " a" , y = " b" , c = " c" , s = 50 )
579
+ df.plot.scatter(x = " a" , y = " b" , c = " c" , s = 50 );
580
580
581
581
582
582
.. ipython :: python
@@ -591,7 +591,7 @@ bubble chart using a column of the ``DataFrame`` as the bubble size.
591
591
.. ipython :: python
592
592
593
593
@savefig scatter_plot_bubble.png
594
- df.plot.scatter(x = " a" , y = " b" , s = df[" c" ] * 200 )
594
+ df.plot.scatter(x = " a" , y = " b" , s = df[" c" ] * 200 );
595
595
596
596
.. ipython :: python
597
597
:suppress:
@@ -837,7 +837,7 @@ You can create a scatter plot matrix using the
837
837
df = pd.DataFrame(np.random.randn(1000 , 4 ), columns = [" a" , " b" , " c" , " d" ])
838
838
839
839
@savefig scatter_matrix_kde.png
840
- scatter_matrix(df, alpha = 0.2 , figsize = (6 , 6 ), diagonal = " kde" )
840
+ scatter_matrix(df, alpha = 0.2 , figsize = (6 , 6 ), diagonal = " kde" );
841
841
842
842
.. ipython :: python
843
843
:suppress:
@@ -1086,7 +1086,7 @@ layout and formatting of the returned plot:
1086
1086
1087
1087
plt.figure();
1088
1088
@savefig series_plot_basic2.png
1089
- ts.plot(style = " k--" , label = " Series" )
1089
+ ts.plot(style = " k--" , label = " Series" );
1090
1090
1091
1091
.. ipython :: python
1092
1092
:suppress:
@@ -1144,7 +1144,7 @@ it empty for ylabel.
1144
1144
df.plot();
1145
1145
1146
1146
@savefig plot_xlabel_ylabel.png
1147
- df.plot(xlabel = " new x" , ylabel = " new y" )
1147
+ df.plot(xlabel = " new x" , ylabel = " new y" );
1148
1148
1149
1149
.. ipython :: python
1150
1150
:suppress:
@@ -1320,7 +1320,7 @@ with the ``subplots`` keyword:
1320
1320
.. ipython :: python
1321
1321
1322
1322
@savefig frame_plot_subplots.png
1323
- df.plot(subplots = True , figsize = (6 , 6 ))
1323
+ df.plot(subplots = True , figsize = (6 , 6 ));
1324
1324
1325
1325
.. ipython :: python
1326
1326
:suppress:
@@ -1343,7 +1343,7 @@ or columns needed, given the other.
1343
1343
.. ipython :: python
1344
1344
1345
1345
@savefig frame_plot_subplots_layout.png
1346
- df.plot(subplots = True , layout = (2 , 3 ), figsize = (6 , 6 ), sharex = False )
1346
+ df.plot(subplots = True , layout = (2 , 3 ), figsize = (6 , 6 ), sharex = False );
1347
1347
1348
1348
.. ipython :: python
1349
1349
:suppress:
@@ -1354,7 +1354,7 @@ The above example is identical to using:
1354
1354
1355
1355
.. ipython :: python
1356
1356
1357
- df.plot(subplots = True , layout = (2 , - 1 ), figsize = (6 , 6 ), sharex = False )
1357
+ df.plot(subplots = True , layout = (2 , - 1 ), figsize = (6 , 6 ), sharex = False );
1358
1358
1359
1359
.. ipython :: python
1360
1360
:suppress:
@@ -1379,9 +1379,9 @@ otherwise you will see a warning.
1379
1379
target1 = [axes[0 ][0 ], axes[1 ][1 ], axes[2 ][2 ], axes[3 ][3 ]]
1380
1380
target2 = [axes[3 ][0 ], axes[2 ][1 ], axes[1 ][2 ], axes[0 ][3 ]]
1381
1381
1382
- df.plot(subplots = True , ax = target1, legend = False , sharex = False , sharey = False )
1382
+ df.plot(subplots = True , ax = target1, legend = False , sharex = False , sharey = False );
1383
1383
@savefig frame_plot_subplots_multi_ax.png
1384
- (- df).plot(subplots = True , ax = target2, legend = False , sharex = False , sharey = False )
1384
+ (- df).plot(subplots = True , ax = target2, legend = False , sharex = False , sharey = False );
1385
1385
1386
1386
.. ipython :: python
1387
1387
:suppress:
@@ -1409,15 +1409,15 @@ Another option is passing an ``ax`` argument to :meth:`Series.plot` to plot on a
1409
1409
1410
1410
fig, axes = plt.subplots(nrows = 2 , ncols = 2 )
1411
1411
plt.subplots_adjust(wspace = 0.2 , hspace = 0.5 )
1412
- df[" A" ].plot(ax = axes[0 , 0 ])
1413
- axes[0 , 0 ].set_title(" A" )
1414
- df[" B" ].plot(ax = axes[0 , 1 ])
1415
- axes[0 , 1 ].set_title(" B" )
1416
- df[" C" ].plot(ax = axes[1 , 0 ])
1417
- axes[1 , 0 ].set_title(" C" )
1418
- df[" D" ].plot(ax = axes[1 , 1 ])
1412
+ df[" A" ].plot(ax = axes[0 , 0 ]);
1413
+ axes[0 , 0 ].set_title(" A" );
1414
+ df[" B" ].plot(ax = axes[0 , 1 ]);
1415
+ axes[0 , 1 ].set_title(" B" );
1416
+ df[" C" ].plot(ax = axes[1 , 0 ]);
1417
+ axes[1 , 0 ].set_title(" C" );
1418
+ df[" D" ].plot(ax = axes[1 , 1 ]);
1419
1419
@savefig series_plot_multi.png
1420
- axes[1 , 1 ].set_title(" D" )
1420
+ axes[1 , 1 ].set_title(" D" );
1421
1421
1422
1422
.. ipython :: python
1423
1423
:suppress:
0 commit comments