@@ -161,22 +161,22 @@ def test_plot_fails_when_ax_differs_from_figure(self):
161
161
@slow
162
162
def test_autocorrelation_plot (self ):
163
163
from pandas .tools .plotting import autocorrelation_plot
164
- _check_plot_works (autocorrelation_plot , self .ts )
165
- _check_plot_works (autocorrelation_plot , self .ts .values )
164
+ _check_plot_works (autocorrelation_plot , series = self .ts )
165
+ _check_plot_works (autocorrelation_plot , series = self .ts .values )
166
166
167
167
ax = autocorrelation_plot (self .ts , label = 'Test' )
168
168
self ._check_legend_labels (ax , labels = ['Test' ])
169
169
170
170
@slow
171
171
def test_lag_plot (self ):
172
172
from pandas .tools .plotting import lag_plot
173
- _check_plot_works (lag_plot , self .ts )
174
- _check_plot_works (lag_plot , self .ts , lag = 5 )
173
+ _check_plot_works (lag_plot , series = self .ts )
174
+ _check_plot_works (lag_plot , series = self .ts , lag = 5 )
175
175
176
176
@slow
177
177
def test_bootstrap_plot (self ):
178
178
from pandas .tools .plotting import bootstrap_plot
179
- _check_plot_works (bootstrap_plot , self .ts , size = 10 )
179
+ _check_plot_works (bootstrap_plot , series = self .ts , size = 10 )
180
180
181
181
182
182
@tm .mplskip
@@ -210,7 +210,7 @@ def test_boxplot_legacy(self):
210
210
_check_plot_works (df .boxplot , column = 'one' , by = ['indic' , 'indic2' ])
211
211
_check_plot_works (df .boxplot , by = 'indic' )
212
212
_check_plot_works (df .boxplot , by = ['indic' , 'indic2' ])
213
- _check_plot_works (plotting .boxplot , df ['one' ], return_type = 'dict' )
213
+ _check_plot_works (plotting .boxplot , data = df ['one' ], return_type = 'dict' )
214
214
_check_plot_works (df .boxplot , notch = 1 , return_type = 'dict' )
215
215
_check_plot_works (df .boxplot , by = 'indic' , notch = 1 )
216
216
@@ -304,6 +304,7 @@ def test_boxplot_empty_column(self):
304
304
305
305
@slow
306
306
def test_hist_df_legacy (self ):
307
+ from matplotlib .patches import Rectangle
307
308
_check_plot_works (self .hist_df .hist )
308
309
309
310
# make sure layout is handled
@@ -347,7 +348,8 @@ def test_hist_df_legacy(self):
347
348
# make sure kwargs to hist are handled
348
349
ax = ser .hist (normed = True , cumulative = True , bins = 4 )
349
350
# height of last bin (index 5) must be 1.0
350
- self .assertAlmostEqual (ax .get_children ()[5 ].get_height (), 1.0 )
351
+ rects = [x for x in ax .get_children () if isinstance (x , Rectangle )]
352
+ self .assertAlmostEqual (rects [- 1 ].get_height (), 1.0 )
351
353
352
354
tm .close ()
353
355
ax = ser .hist (log = True )
@@ -413,9 +415,9 @@ def scat(**kwds):
413
415
def scat2 (x , y , by = None , ax = None , figsize = None ):
414
416
return plotting .scatter_plot (df , x , y , by , ax , figsize = None )
415
417
416
- _check_plot_works (scat2 , 0 , 1 )
418
+ _check_plot_works (scat2 , x = 0 , y = 1 )
417
419
grouper = Series (np .repeat ([1 , 2 , 3 , 4 , 5 ], 20 ), df .index )
418
- _check_plot_works (scat2 , 0 , 1 , by = grouper )
420
+ _check_plot_works (scat2 , x = 0 , y = 1 , by = grouper )
419
421
420
422
def test_scatter_matrix_axis (self ):
421
423
tm ._skip_if_no_scipy ()
@@ -424,15 +426,17 @@ def test_scatter_matrix_axis(self):
424
426
with tm .RNGContext (42 ):
425
427
df = DataFrame (randn (100 , 3 ))
426
428
427
- axes = _check_plot_works (scatter_matrix , df , range_padding = .1 )
429
+ axes = _check_plot_works (scatter_matrix , filterwarnings = 'always' , frame = df ,
430
+ range_padding = .1 )
428
431
axes0_labels = axes [0 ][0 ].yaxis .get_majorticklabels ()
429
432
# GH 5662
430
433
expected = ['-2' , '-1' , '0' , '1' , '2' ]
431
434
self ._check_text_labels (axes0_labels , expected )
432
435
self ._check_ticks_props (axes , xlabelsize = 8 , xrot = 90 , ylabelsize = 8 , yrot = 0 )
433
436
434
437
df [0 ] = ((df [0 ] - 2 ) / 3 )
435
- axes = _check_plot_works (scatter_matrix , df , range_padding = .1 )
438
+ axes = _check_plot_works (scatter_matrix , filterwarnings = 'always' , frame = df ,
439
+ range_padding = .1 )
436
440
axes0_labels = axes [0 ][0 ].yaxis .get_majorticklabels ()
437
441
expected = ['-1.2' , '-1.0' , '-0.8' , '-0.6' , '-0.4' , '-0.2' , '0.0' ]
438
442
self ._check_text_labels (axes0_labels , expected )
@@ -445,17 +449,17 @@ def test_andrews_curves(self):
445
449
446
450
df = self .iris
447
451
448
- _check_plot_works (andrews_curves , df , 'Name' )
452
+ _check_plot_works (andrews_curves , frame = df , class_column = 'Name' )
449
453
450
454
rgba = ('#556270' , '#4ECDC4' , '#C7F464' )
451
- ax = _check_plot_works (andrews_curves , df , 'Name' , color = rgba )
455
+ ax = _check_plot_works (andrews_curves , frame = df , class_column = 'Name' , color = rgba )
452
456
self ._check_colors (ax .get_lines ()[:10 ], linecolors = rgba , mapping = df ['Name' ][:10 ])
453
457
454
458
cnames = ['dodgerblue' , 'aquamarine' , 'seagreen' ]
455
- ax = _check_plot_works (andrews_curves , df , 'Name' , color = cnames )
459
+ ax = _check_plot_works (andrews_curves , frame = df , class_column = 'Name' , color = cnames )
456
460
self ._check_colors (ax .get_lines ()[:10 ], linecolors = cnames , mapping = df ['Name' ][:10 ])
457
461
458
- ax = _check_plot_works (andrews_curves , df , 'Name' , colormap = cm .jet )
462
+ ax = _check_plot_works (andrews_curves , frame = df , class_column = 'Name' , colormap = cm .jet )
459
463
cmaps = lmap (cm .jet , np .linspace (0 , 1 , df ['Name' ].nunique ()))
460
464
self ._check_colors (ax .get_lines ()[:10 ], linecolors = cmaps , mapping = df ['Name' ][:10 ])
461
465
@@ -478,23 +482,23 @@ def test_parallel_coordinates(self):
478
482
479
483
df = self .iris
480
484
481
- ax = _check_plot_works (parallel_coordinates , df , 'Name' )
485
+ ax = _check_plot_works (parallel_coordinates , frame = df , class_column = 'Name' )
482
486
nlines = len (ax .get_lines ())
483
487
nxticks = len (ax .xaxis .get_ticklabels ())
484
488
485
489
rgba = ('#556270' , '#4ECDC4' , '#C7F464' )
486
- ax = _check_plot_works (parallel_coordinates , df , 'Name' , color = rgba )
490
+ ax = _check_plot_works (parallel_coordinates , frame = df , class_column = 'Name' , color = rgba )
487
491
self ._check_colors (ax .get_lines ()[:10 ], linecolors = rgba , mapping = df ['Name' ][:10 ])
488
492
489
493
cnames = ['dodgerblue' , 'aquamarine' , 'seagreen' ]
490
- ax = _check_plot_works (parallel_coordinates , df , 'Name' , color = cnames )
494
+ ax = _check_plot_works (parallel_coordinates , frame = df , class_column = 'Name' , color = cnames )
491
495
self ._check_colors (ax .get_lines ()[:10 ], linecolors = cnames , mapping = df ['Name' ][:10 ])
492
496
493
- ax = _check_plot_works (parallel_coordinates , df , 'Name' , colormap = cm .jet )
497
+ ax = _check_plot_works (parallel_coordinates , frame = df , class_column = 'Name' , colormap = cm .jet )
494
498
cmaps = lmap (cm .jet , np .linspace (0 , 1 , df ['Name' ].nunique ()))
495
499
self ._check_colors (ax .get_lines ()[:10 ], linecolors = cmaps , mapping = df ['Name' ][:10 ])
496
500
497
- ax = _check_plot_works (parallel_coordinates , df , 'Name' , axvlines = False )
501
+ ax = _check_plot_works (parallel_coordinates , frame = df , class_column = 'Name' , axvlines = False )
498
502
assert len (ax .get_lines ()) == (nlines - nxticks )
499
503
500
504
colors = ['b' , 'g' , 'r' ]
@@ -517,20 +521,20 @@ def test_radviz(self):
517
521
from matplotlib import cm
518
522
519
523
df = self .iris
520
- _check_plot_works (radviz , df , 'Name' )
524
+ _check_plot_works (radviz , frame = df , class_column = 'Name' )
521
525
522
526
rgba = ('#556270' , '#4ECDC4' , '#C7F464' )
523
- ax = _check_plot_works (radviz , df , 'Name' , color = rgba )
527
+ ax = _check_plot_works (radviz , frame = df , class_column = 'Name' , color = rgba )
524
528
# skip Circle drawn as ticks
525
529
patches = [p for p in ax .patches [:20 ] if p .get_label () != '' ]
526
530
self ._check_colors (patches [:10 ], facecolors = rgba , mapping = df ['Name' ][:10 ])
527
531
528
532
cnames = ['dodgerblue' , 'aquamarine' , 'seagreen' ]
529
- _check_plot_works (radviz , df , 'Name' , color = cnames )
533
+ _check_plot_works (radviz , frame = df , class_column = 'Name' , color = cnames )
530
534
patches = [p for p in ax .patches [:20 ] if p .get_label () != '' ]
531
535
self ._check_colors (patches , facecolors = cnames , mapping = df ['Name' ][:10 ])
532
536
533
- _check_plot_works (radviz , df , 'Name' , colormap = cm .jet )
537
+ _check_plot_works (radviz , frame = df , class_column = 'Name' , colormap = cm .jet )
534
538
cmaps = lmap (cm .jet , np .linspace (0 , 1 , df ['Name' ].nunique ()))
535
539
patches = [p for p in ax .patches [:20 ] if p .get_label () != '' ]
536
540
self ._check_colors (patches , facecolors = cmaps , mapping = df ['Name' ][:10 ])
@@ -607,6 +611,8 @@ def test_grouped_plot_fignums(self):
607
611
608
612
@slow
609
613
def test_grouped_hist_legacy (self ):
614
+ from matplotlib .patches import Rectangle
615
+
610
616
df = DataFrame (randn (500 , 2 ), columns = ['A' , 'B' ])
611
617
df ['C' ] = np .random .randint (0 , 4 , 500 )
612
618
df ['D' ] = ['X' ] * 500
@@ -633,7 +639,8 @@ def test_grouped_hist_legacy(self):
633
639
xlabelsize = xf , xrot = xrot , ylabelsize = yf , yrot = yrot )
634
640
# height of last bin (index 5) must be 1.0
635
641
for ax in axes .ravel ():
636
- height = ax .get_children ()[5 ].get_height ()
642
+ rects = [x for x in ax .get_children () if isinstance (x , Rectangle )]
643
+ height = rects [- 1 ].get_height ()
637
644
self .assertAlmostEqual (height , 1.0 )
638
645
self ._check_ticks_props (axes , xlabelsize = xf , xrot = xrot ,
639
646
ylabelsize = yf , yrot = yrot )
0 commit comments