@@ -117,8 +117,12 @@ def scatter_matrix(
117
117
118
118
Examples
119
119
--------
120
- >>> df = pd.DataFrame(np.random.randn(1000, 4), columns=['A','B','C','D'])
121
- >>> scatter_matrix(df, alpha=0.2)
120
+
121
+ .. plot::
122
+ :context: close-figs
123
+
124
+ >>> df = pd.DataFrame(np.random.randn(1000, 4), columns=['A','B','C','D'])
125
+ >>> pd.plotting.scatter_matrix(df, alpha=0.2)
122
126
"""
123
127
plot_backend = _get_plot_backend ("matplotlib" )
124
128
return plot_backend .scatter_matrix (
@@ -179,24 +183,31 @@ def radviz(frame, class_column, ax=None, color=None, colormap=None, **kwds):
179
183
180
184
Examples
181
185
--------
186
+
182
187
.. plot::
183
188
:context: close-figs
184
189
185
- >>> df = pd.DataFrame({
186
- ... 'SepalLength': [6.5, 7.7, 5.1, 5.8, 7.6, 5.0, 5.4, 4.6,
187
- ... 6.7, 4.6],
188
- ... 'SepalWidth': [3.0, 3.8, 3.8, 2.7, 3.0, 2.3, 3.0, 3.2,
189
- ... 3.3, 3.6],
190
- ... 'PetalLength': [5.5, 6.7, 1.9, 5.1, 6.6, 3.3, 4.5, 1.4,
191
- ... 5.7, 1.0],
192
- ... 'PetalWidth': [1.8, 2.2, 0.4, 1.9, 2.1, 1.0, 1.5, 0.2,
193
- ... 2.1, 0.2],
194
- ... 'Category': ['virginica', 'virginica', 'setosa',
195
- ... 'virginica', 'virginica', 'versicolor',
196
- ... 'versicolor', 'setosa', 'virginica',
197
- ... 'setosa']
198
- ... })
199
- >>> rad_viz = pd.plotting.radviz(df, 'Category') # doctest: +SKIP
190
+ >>> df = pd.DataFrame(
191
+ ... {
192
+ ... 'SepalLength': [6.5, 7.7, 5.1, 5.8, 7.6, 5.0, 5.4, 4.6, 6.7, 4.6],
193
+ ... 'SepalWidth': [3.0, 3.8, 3.8, 2.7, 3.0, 2.3, 3.0, 3.2, 3.3, 3.6],
194
+ ... 'PetalLength': [5.5, 6.7, 1.9, 5.1, 6.6, 3.3, 4.5, 1.4, 5.7, 1.0],
195
+ ... 'PetalWidth': [1.8, 2.2, 0.4, 1.9, 2.1, 1.0, 1.5, 0.2, 2.1, 0.2],
196
+ ... 'Category': [
197
+ ... 'virginica',
198
+ ... 'virginica',
199
+ ... 'setosa',
200
+ ... 'virginica',
201
+ ... 'virginica',
202
+ ... 'versicolor',
203
+ ... 'versicolor',
204
+ ... 'setosa',
205
+ ... 'virginica',
206
+ ... 'setosa'
207
+ ... ]
208
+ ... }
209
+ ... )
210
+ >>> pd.plotting.radviz(df, 'Category')
200
211
"""
201
212
plot_backend = _get_plot_backend ("matplotlib" )
202
213
return plot_backend .radviz (
@@ -243,6 +254,18 @@ def andrews_curves(
243
254
Returns
244
255
-------
245
256
class:`matplotlip.axis.Axes`
257
+
258
+ Examples
259
+ --------
260
+
261
+ .. plot::
262
+ :context: close-figs
263
+
264
+ >>> df = pd.read_csv(
265
+ ... 'https://raw.github.com/pandas-dev/'
266
+ ... 'pandas/master/pandas/tests/data/iris.csv'
267
+ ... )
268
+ >>> pd.plotting.andrews_curves(df, 'Name')
246
269
"""
247
270
plot_backend = _get_plot_backend ("matplotlib" )
248
271
return plot_backend .andrews_curves (
@@ -298,10 +321,10 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
298
321
This example draws a basic bootstap plot for a Series.
299
322
300
323
.. plot::
301
- :context: close-figs
324
+ :context: close-figs
302
325
303
- >>> s = pd.Series(np.random.uniform(size=100))
304
- >>> fig = pd.plotting.bootstrap_plot(s) # doctest: +SKIP
326
+ >>> s = pd.Series(np.random.uniform(size=100))
327
+ >>> pd.plotting.bootstrap_plot(s)
305
328
"""
306
329
plot_backend = _get_plot_backend ("matplotlib" )
307
330
return plot_backend .bootstrap_plot (
@@ -358,13 +381,17 @@ def parallel_coordinates(
358
381
359
382
Examples
360
383
--------
361
- >>> from matplotlib import pyplot as plt
362
- >>> df = pd.read_csv('https://raw.github.com/pandas-dev/pandas/master'
363
- '/pandas/tests/data/iris.csv')
364
- >>> pd.plotting.parallel_coordinates(
365
- df, 'Name',
366
- color=('#556270', '#4ECDC4', '#C7F464'))
367
- >>> plt.show()
384
+
385
+ .. plot::
386
+ :context: close-figs
387
+
388
+ >>> df = pd.read_csv(
389
+ ... 'https://raw.github.com/pandas-dev/'
390
+ ... 'pandas/master/pandas/tests/data/iris.csv'
391
+ ... )
392
+ >>> pd.plotting.parallel_coordinates(
393
+ ... df, 'Name', color=('#556270', '#4ECDC4', '#C7F464')
394
+ ... )
368
395
"""
369
396
plot_backend = _get_plot_backend ("matplotlib" )
370
397
return plot_backend .parallel_coordinates (
@@ -398,6 +425,28 @@ def lag_plot(series, lag=1, ax=None, **kwds):
398
425
Returns
399
426
-------
400
427
class:`matplotlib.axis.Axes`
428
+
429
+ Examples
430
+ --------
431
+
432
+ Lag plots are most commonly used to look for patterns in time series data.
433
+
434
+ Given the following time series
435
+
436
+ .. plot::
437
+ :context: close-figs
438
+
439
+ >>> np.random.seed(5)
440
+ >>> x = np.cumsum(np.random.normal(loc=1, scale=5, size=50))
441
+ >>> s = pd.Series(x)
442
+ >>> s.plot()
443
+
444
+ A lag plot with ``lag=1`` returns
445
+
446
+ .. plot::
447
+ :context: close-figs
448
+
449
+ >>> pd.plotting.lag_plot(s, lag=1)
401
450
"""
402
451
plot_backend = _get_plot_backend ("matplotlib" )
403
452
return plot_backend .lag_plot (series = series , lag = lag , ax = ax , ** kwds )
@@ -417,6 +466,20 @@ def autocorrelation_plot(series, ax=None, **kwargs):
417
466
Returns
418
467
-------
419
468
class:`matplotlib.axis.Axes`
469
+
470
+ Examples
471
+ --------
472
+
473
+ The horizontal lines in the plot correspond to 95% and 99% confidence bands.
474
+
475
+ The dashed line is 99% confidence band.
476
+
477
+ .. plot::
478
+ :context: close-figs
479
+
480
+ >>> spacing = np.linspace(-9 * np.pi, 9 * np.pi, num=1000)
481
+ >>> s = pd.Series(0.7 * np.random.rand(1000) + 0.3 * np.sin(spacing))
482
+ >>> pd.plotting.autocorrelation_plot(s)
420
483
"""
421
484
plot_backend = _get_plot_backend ("matplotlib" )
422
485
return plot_backend .autocorrelation_plot (series = series , ax = ax , ** kwargs )
0 commit comments