@@ -79,7 +79,6 @@ On DataFrame, :meth:`~DataFrame.plot` is a convenience to plot all of the column
79
79
df = df.cumsum()
80
80
81
81
@savefig frame_plot_basic.png
82
- plt.figure()
83
82
df.plot()
84
83
85
84
You can plot one column versus another using the `x ` and `y ` keywords in
@@ -89,7 +88,6 @@ You can plot one column versus another using the `x` and `y` keywords in
89
88
:suppress:
90
89
91
90
plt.close(' all' )
92
- plt.figure()
93
91
np.random.seed(123456 )
94
92
95
93
.. ipython :: python
@@ -132,8 +130,6 @@ For example, a bar plot can be created the following way:
132
130
133
131
.. ipython :: python
134
132
135
- plt.figure()
136
-
137
133
@savefig bar_plot_ex.png
138
134
df.iloc[5 ].plot(kind = ' bar' )
139
135
@@ -178,8 +174,6 @@ For labeled, non-time series data, you may wish to produce a bar plot:
178
174
179
175
.. ipython :: python
180
176
181
- plt.figure()
182
-
183
177
@savefig bar_plot_ex.png
184
178
df.iloc[5 ].plot.bar(); plt.axhline(0 , color = ' k' )
185
179
@@ -190,7 +184,6 @@ bar plot:
190
184
:suppress:
191
185
192
186
plt.close(' all' )
193
- plt.figure()
194
187
np.random.seed(123456 )
195
188
196
189
.. ipython :: python
@@ -206,7 +199,6 @@ To produce a stacked bar plot, pass ``stacked=True``:
206
199
:suppress:
207
200
208
201
plt.close(' all' )
209
- plt.figure()
210
202
211
203
.. ipython :: python
212
204
@@ -219,7 +211,6 @@ To get horizontal bar plots, use the ``barh`` method:
219
211
:suppress:
220
212
221
213
plt.close(' all' )
222
- plt.figure()
223
214
224
215
.. ipython :: python
225
216
@@ -238,8 +229,6 @@ Histograms can be drawn by using the :meth:`DataFrame.plot.hist` and :meth:`Seri
238
229
df4 = pd.DataFrame({' a' : np.random.randn(1000 ) + 1 , ' b' : np.random.randn(1000 ),
239
230
' c' : np.random.randn(1000 ) - 1 }, columns = [' a' , ' b' , ' c' ])
240
231
241
- plt.figure()
242
-
243
232
@savefig hist_new.png
244
233
df4.plot.hist(alpha = 0.5 )
245
234
@@ -254,8 +243,6 @@ using the ``bins`` keyword.
254
243
255
244
.. ipython :: python
256
245
257
- plt.figure()
258
-
259
246
@savefig hist_new_stacked.png
260
247
df4.plot.hist(stacked = True , bins = 20 )
261
248
@@ -270,8 +257,6 @@ horizontal and cumulative histograms can be drawn by
270
257
271
258
.. ipython :: python
272
259
273
- plt.figure()
274
-
275
260
@savefig hist_new_kwargs.png
276
261
df4[' a' ].plot.hist(orientation = ' horizontal' , cumulative = True )
277
262
@@ -288,8 +273,6 @@ The existing interface ``DataFrame.hist`` to plot histogram still can be used.
288
273
289
274
.. ipython :: python
290
275
291
- plt.figure()
292
-
293
276
@savefig hist_plot_ex.png
294
277
df[' A' ].diff().hist()
295
278
@@ -303,8 +286,6 @@ subplots:
303
286
304
287
.. ipython :: python
305
288
306
- plt.figure()
307
-
308
289
@savefig frame_hist_ex.png
309
290
df.diff().hist(color = ' k' , alpha = 0.5 , bins = 50 )
310
291
@@ -315,7 +296,6 @@ The ``by`` keyword can be specified to plot grouped histograms:
315
296
:suppress:
316
297
317
298
plt.close(' all' )
318
- plt.figure()
319
299
np.random.seed(123456 )
320
300
321
301
.. ipython :: python
@@ -402,7 +382,6 @@ The existing interface ``DataFrame.boxplot`` to plot boxplot still can be used.
402
382
:okwarning:
403
383
404
384
df = pd.DataFrame(np.random.rand(10 , 5 ))
405
- plt.figure()
406
385
407
386
@savefig box_plot_ex.png
408
387
bp = df.boxplot()
@@ -422,8 +401,6 @@ groupings. For instance,
422
401
df = pd.DataFrame(np.random.rand(10 , 2 ), columns = [' Col1' , ' Col2' ])
423
402
df[' X' ] = pd.Series([' A' , ' A' , ' A' , ' A' , ' A' , ' B' , ' B' , ' B' , ' B' , ' B' ])
424
403
425
- plt.figure()
426
-
427
404
@savefig box_plot_ex2.png
428
405
bp = df.boxplot(by = ' X' )
429
406
@@ -443,8 +420,6 @@ columns:
443
420
df[' X' ] = pd.Series([' A' , ' A' , ' A' , ' A' , ' A' , ' B' , ' B' , ' B' , ' B' , ' B' ])
444
421
df[' Y' ] = pd.Series([' A' , ' B' , ' A' , ' B' , ' A' , ' B' , ' A' , ' B' , ' A' , ' B' ])
445
422
446
- plt.figure()
447
-
448
423
@savefig box_plot_ex3.png
449
424
bp = df.boxplot(column = [' Col1' , ' Col2' ], by = [' X' , ' Y' ])
450
425
@@ -524,7 +499,6 @@ When input data contains `NaN`, it will be automatically filled by 0. If you wan
524
499
:suppress:
525
500
526
501
np.random.seed(123456 )
527
- plt.figure()
528
502
529
503
.. ipython :: python
530
504
@@ -539,7 +513,6 @@ To produce an unstacked plot, pass ``stacked=False``. Alpha value is set to 0.5
539
513
:suppress:
540
514
541
515
plt.close(' all' )
542
- plt.figure()
543
516
544
517
.. ipython :: python
545
518
@@ -560,7 +533,6 @@ These can be specified by the ``x`` and ``y`` keywords.
560
533
561
534
np.random.seed(123456 )
562
535
plt.close(' all' )
563
- plt.figure()
564
536
565
537
.. ipython :: python
566
538
@@ -626,7 +598,6 @@ too dense to plot each point individually.
626
598
.. ipython :: python
627
599
:suppress:
628
600
629
- plt.figure()
630
601
np.random.seed(123456 )
631
602
632
603
.. ipython :: python
@@ -654,7 +625,6 @@ given by column ``z``. The bins are aggregated with NumPy's ``max`` function.
654
625
:suppress:
655
626
656
627
plt.close(' all' )
657
- plt.figure()
658
628
np.random.seed(123456 )
659
629
660
630
.. ipython :: python
@@ -688,7 +658,6 @@ A ``ValueError`` will be raised if there are any negative values in your data.
688
658
:suppress:
689
659
690
660
np.random.seed(123456 )
691
- plt.figure()
692
661
693
662
.. ipython :: python
694
663
@@ -718,7 +687,6 @@ drawn in each pie plots by default; specify ``legend=False`` to hide it.
718
687
:suppress:
719
688
720
689
np.random.seed(123456 )
721
- plt.figure()
722
690
723
691
.. ipython :: python
724
692
@@ -744,12 +712,6 @@ If you want to hide wedge labels, specify ``labels=None``.
744
712
If ``fontsize `` is specified, the value will be applied to wedge labels.
745
713
Also, other keywords supported by :func: `matplotlib.pyplot.pie ` can be used.
746
714
747
-
748
- .. ipython :: python
749
- :suppress:
750
-
751
- plt.figure()
752
-
753
715
.. ipython :: python
754
716
755
717
@savefig series_pie_plot_options.png
@@ -762,7 +724,6 @@ If you pass values whose sum total is less than 1.0, matplotlib draws a semicirc
762
724
:suppress:
763
725
764
726
plt.close(' all' )
765
- plt.figure()
766
727
767
728
.. ipython :: python
768
729
@@ -860,7 +821,6 @@ You can create density plots using the :meth:`Series.plot.kde` and :meth:`DataFr
860
821
.. ipython :: python
861
822
:suppress:
862
823
863
- plt.figure()
864
824
np.random.seed(123456 )
865
825
866
826
.. ipython :: python
@@ -895,8 +855,6 @@ of the same class will usually be closer together and form larger structures.
895
855
896
856
data = pd.read_csv(' data/iris.data' )
897
857
898
- plt.figure()
899
-
900
858
@savefig andrews_curves.png
901
859
andrews_curves(data, ' Name' )
902
860
@@ -919,8 +877,6 @@ represents one data point. Points that tend to cluster will appear closer togeth
919
877
920
878
data = pd.read_csv(' data/iris.data' )
921
879
922
- plt.figure()
923
-
924
880
@savefig parallel_coordinates.png
925
881
parallel_coordinates(data, ' Name' )
926
882
@@ -949,8 +905,6 @@ be passed, and when ``lag=1`` the plot is essentially ``data[:-1]`` vs.
949
905
950
906
from pandas.plotting import lag_plot
951
907
952
- plt.figure()
953
-
954
908
spacing = np.linspace(- 99 * np.pi, 99 * np.pi, num = 1000 )
955
909
data = pd.Series(0.1 * np.random.rand(1000 ) + 0.9 * np.sin(spacing))
956
910
@@ -986,8 +940,6 @@ autocorrelation plots.
986
940
987
941
from pandas.plotting import autocorrelation_plot
988
942
989
- plt.figure()
990
-
991
943
spacing = np.linspace(- 9 * np.pi, 9 * np.pi, num = 1000 )
992
944
data = pd.Series(0.7 * np.random.rand(1000 ) + 0.3 * np.sin(spacing))
993
945
@@ -1055,8 +1007,6 @@ for more information.
1055
1007
1056
1008
data = pd.read_csv(' data/iris.data' )
1057
1009
1058
- plt.figure()
1059
-
1060
1010
@savefig radviz.png
1061
1011
radviz(data, ' Name' )
1062
1012
@@ -1091,7 +1041,7 @@ layout and formatting of the returned plot:
1091
1041
.. ipython :: python
1092
1042
1093
1043
@savefig series_plot_basic2.png
1094
- plt.figure(); ts.plot(style = ' k--' , label = ' Series' )
1044
+ ts.plot(style = ' k--' , label = ' Series' )
1095
1045
1096
1046
.. ipython :: python
1097
1047
:suppress:
@@ -1138,7 +1088,6 @@ You may pass ``logy`` to get a log-scale Y axis.
1138
1088
.. ipython :: python
1139
1089
:suppress:
1140
1090
1141
- plt.figure()
1142
1091
np.random.seed(123456 )
1143
1092
1144
1093
.. ipython :: python
@@ -1162,11 +1111,6 @@ Plotting on a Secondary Y-axis
1162
1111
1163
1112
To plot data on a secondary y-axis, use the ``secondary_y `` keyword:
1164
1113
1165
- .. ipython :: python
1166
- :suppress:
1167
-
1168
- plt.figure()
1169
-
1170
1114
.. ipython :: python
1171
1115
1172
1116
df.A.plot()
@@ -1184,7 +1128,6 @@ keyword:
1184
1128
1185
1129
.. ipython :: python
1186
1130
1187
- plt.figure()
1188
1131
ax = df.plot(secondary_y = [' A' , ' B' ])
1189
1132
ax.set_ylabel(' CD scale' )
1190
1133
@savefig frame_plot_secondary_y.png
@@ -1201,8 +1144,6 @@ with "(right)" in the legend. To turn off the automatic marking, use the
1201
1144
1202
1145
.. ipython :: python
1203
1146
1204
- plt.figure()
1205
-
1206
1147
@savefig frame_plot_secondary_y_no_right.png
1207
1148
df.plot(secondary_y = [' A' , ' B' ], mark_right = False )
1208
1149
@@ -1223,8 +1164,6 @@ Here is the default behavior, notice how the x-axis tick labeling is performed:
1223
1164
1224
1165
.. ipython :: python
1225
1166
1226
- plt.figure()
1227
-
1228
1167
@savefig ser_plot_suppress.png
1229
1168
df.A.plot()
1230
1169
@@ -1237,8 +1176,6 @@ Using the ``x_compat`` parameter, you can suppress this behavior:
1237
1176
1238
1177
.. ipython :: python
1239
1178
1240
- plt.figure()
1241
-
1242
1179
@savefig ser_plot_suppress_parm.png
1243
1180
df.A.plot(x_compat = True )
1244
1181
@@ -1252,8 +1189,6 @@ in ``pandas.plotting.plot_params`` can be used in a `with statement`:
1252
1189
1253
1190
.. ipython :: python
1254
1191
1255
- plt.figure()
1256
-
1257
1192
@savefig ser_plot_suppress_context.png
1258
1193
with pd.plotting.plot_params.use(' x_compat' , True ):
1259
1194
df.A.plot(color = ' r' )
@@ -1531,8 +1466,6 @@ To use the cubehelix colormap, we can pass ``colormap='cubehelix'``.
1531
1466
df = pd.DataFrame(np.random.randn(1000 , 10 ), index = ts.index)
1532
1467
df = df.cumsum()
1533
1468
1534
- plt.figure()
1535
-
1536
1469
@savefig cubehelix.png
1537
1470
df.plot(colormap = ' cubehelix' )
1538
1471
@@ -1547,8 +1480,6 @@ Alternatively, we can pass the colormap itself:
1547
1480
1548
1481
from matplotlib import cm
1549
1482
1550
- plt.figure()
1551
-
1552
1483
@savefig cubehelix_cm.png
1553
1484
df.plot(colormap = cm.cubehelix)
1554
1485
@@ -1569,8 +1500,6 @@ Colormaps can also be used other plot types, like bar charts:
1569
1500
dd = pd.DataFrame(np.random.randn(10 , 10 )).applymap(abs )
1570
1501
dd = dd.cumsum()
1571
1502
1572
- plt.figure()
1573
-
1574
1503
@savefig greens.png
1575
1504
dd.plot.bar(colormap = ' Greens' )
1576
1505
@@ -1583,8 +1512,6 @@ Parallel coordinates charts:
1583
1512
1584
1513
.. ipython :: python
1585
1514
1586
- plt.figure()
1587
-
1588
1515
@savefig parallel_gist_rainbow.png
1589
1516
parallel_coordinates(data, ' Name' , colormap = ' gist_rainbow' )
1590
1517
@@ -1597,8 +1524,6 @@ Andrews curves charts:
1597
1524
1598
1525
.. ipython :: python
1599
1526
1600
- plt.figure()
1601
-
1602
1527
@savefig andrews_curve_winter.png
1603
1528
andrews_curves(data, ' Name' , colormap = ' winter' )
1604
1529
@@ -1634,8 +1559,6 @@ when plotting a large number of points.
1634
1559
ma = price.rolling(20 ).mean()
1635
1560
mstd = price.rolling(20 ).std()
1636
1561
1637
- plt.figure()
1638
-
1639
1562
plt.plot(price.index, price, ' k' )
1640
1563
plt.plot(ma.index, ma, ' b' )
1641
1564
@savefig bollinger.png
0 commit comments