@@ -158,14 +158,12 @@ def test_bar_linewidth(self):
158
158
for r in ax .patches :
159
159
self .assert_ (r .get_linewidth () == 2 )
160
160
161
- @slow
162
161
def test_rotation (self ):
163
162
df = DataFrame (np .random .randn (5 , 5 ))
164
163
ax = df .plot (rot = 30 )
165
164
for l in ax .get_xticklabels ():
166
165
self .assert_ (l .get_rotation () == 30 )
167
166
168
- @slow
169
167
def test_irregular_datetime (self ):
170
168
rng = date_range ('1/1/2000' , '3/1/2000' )
171
169
rng = rng [[0 , 1 , 2 , 3 , 5 , 9 , 10 , 11 , 12 ]]
@@ -195,6 +193,36 @@ def test_hist(self):
195
193
self .assertRaises (ValueError , self .ts .hist , by = self .ts .index ,
196
194
figure = fig )
197
195
196
+ @slow
197
+ def test_hist_layout (self ):
198
+ n = 10
199
+ df = DataFrame ({'gender' : np .array (['Male' ,
200
+ 'Female' ])[random .randint (2 ,
201
+ size = n )],
202
+ 'height' : random .normal (66 , 4 , size = n ), 'weight' :
203
+ random .normal (161 , 32 , size = n )})
204
+ self .assertRaises (ValueError , df .height .hist , layout = (1 , 1 ))
205
+ self .assertRaises (ValueError , df .height .hist , layout = [1 , 1 ])
206
+
207
+ @slow
208
+ def test_hist_layout_with_by (self ):
209
+ import matplotlib .pyplot as plt
210
+ n = 10
211
+ df = DataFrame ({'gender' : np .array (['Male' ,
212
+ 'Female' ])[random .randint (2 ,
213
+ size = n )],
214
+ 'height' : random .normal (66 , 4 , size = n ), 'weight' :
215
+ random .normal (161 , 32 , size = n ),
216
+ 'category' : random .randint (4 , size = n )})
217
+ _check_plot_works (df .height .hist , by = df .gender , layout = (2 , 1 ))
218
+ plt .close ('all' )
219
+ _check_plot_works (df .height .hist , by = df .gender , layout = (1 , 2 ))
220
+ plt .close ('all' )
221
+ _check_plot_works (df .weight .hist , by = df .category , layout = (1 , 4 ))
222
+ plt .close ('all' )
223
+ _check_plot_works (df .weight .hist , by = df .category , layout = (4 , 1 ))
224
+ plt .close ('all' )
225
+
198
226
def test_plot_fails_when_ax_differs_from_figure (self ):
199
227
from pylab import figure
200
228
fig1 = figure ()
@@ -210,7 +238,6 @@ def test_kde(self):
210
238
ax = self .ts .plot (kind = 'kde' , logy = True )
211
239
self .assert_ (ax .get_yscale () == 'log' )
212
240
213
- @slow
214
241
def test_kde_color (self ):
215
242
_skip_if_no_scipy ()
216
243
ax = self .ts .plot (kind = 'kde' , logy = True , color = 'r' )
@@ -257,7 +284,6 @@ def test_partially_invalid_plot_data(self):
257
284
for kind in kinds :
258
285
self .assertRaises (TypeError , s .plot , kind = kind )
259
286
260
- @slow
261
287
def test_invalid_kind (self ):
262
288
s = Series ([1 , 2 ])
263
289
self .assertRaises (ValueError , s .plot , kind = 'aasdf' )
@@ -323,7 +349,6 @@ def test_plot(self):
323
349
index = index )
324
350
_check_plot_works (df .plot , title = u'\u03A3 ' )
325
351
326
- @slow
327
352
def test_nonnumeric_exclude (self ):
328
353
import matplotlib .pyplot as plt
329
354
plt .close ('all' )
@@ -410,10 +435,9 @@ def test_xcompat(self):
410
435
lines = ax .get_lines ()
411
436
self .assert_ (isinstance (lines [0 ].get_xdata (), PeriodIndex ))
412
437
413
- @slow
414
438
def test_unsorted_index (self ):
415
- df = DataFrame ({'y' : range (100 )},
416
- index = range (99 , - 1 , - 1 ))
439
+ df = DataFrame ({'y' : np . arange (100 )},
440
+ index = np . arange (99 , - 1 , - 1 ))
417
441
ax = df .plot ()
418
442
l = ax .get_lines ()[0 ]
419
443
rs = l .get_xydata ()
@@ -479,15 +503,13 @@ def test_plot_bar(self):
479
503
df = DataFrame ({'a' : [0 , 1 ], 'b' : [1 , 0 ]})
480
504
_check_plot_works (df .plot , kind = 'bar' )
481
505
482
- @slow
483
506
def test_bar_stacked_center (self ):
484
507
# GH2157
485
508
df = DataFrame ({'A' : [3 ] * 5 , 'B' : range (5 )}, index = range (5 ))
486
509
ax = df .plot (kind = 'bar' , stacked = 'True' , grid = True )
487
510
self .assertEqual (ax .xaxis .get_ticklocs ()[0 ],
488
511
ax .patches [0 ].get_x () + ax .patches [0 ].get_width () / 2 )
489
512
490
- @slow
491
513
def test_bar_center (self ):
492
514
df = DataFrame ({'A' : [3 ] * 5 , 'B' : range (5 )}, index = range (5 ))
493
515
ax = df .plot (kind = 'bar' , grid = True )
@@ -710,7 +732,6 @@ def test_plot_int_columns(self):
710
732
df = DataFrame (np .random .randn (100 , 4 )).cumsum ()
711
733
_check_plot_works (df .plot , legend = True )
712
734
713
- @slow
714
735
def test_legend_name (self ):
715
736
multi = DataFrame (np .random .randn (4 , 4 ),
716
737
columns = [np .array (['a' , 'a' , 'b' , 'b' ]),
@@ -800,7 +821,6 @@ def test_line_colors(self):
800
821
plt .close ('all' )
801
822
df .ix [:, [0 ]].plot (color = 'DodgerBlue' )
802
823
803
- @slow
804
824
def test_default_color_cycle (self ):
805
825
import matplotlib .pyplot as plt
806
826
plt .rcParams ['axes.color_cycle' ] = list ('rgbk' )
@@ -815,7 +835,6 @@ def test_default_color_cycle(self):
815
835
rs = l .get_color ()
816
836
self .assert_ (xp == rs )
817
837
818
- @slow
819
838
def test_unordered_ts (self ):
820
839
df = DataFrame (np .array ([3.0 , 2.0 , 1.0 ]),
821
840
index = [date (2012 , 10 , 1 ),
@@ -828,7 +847,6 @@ def test_unordered_ts(self):
828
847
ydata = ax .lines [0 ].get_ydata ()
829
848
self .assert_ (np .all (ydata == np .array ([1.0 , 2.0 , 3.0 ])))
830
849
831
- @slow
832
850
def test_all_invalid_plot_data (self ):
833
851
kinds = 'line' , 'bar' , 'barh' , 'kde' , 'density'
834
852
df = DataFrame (list ('abcd' ))
@@ -843,7 +861,6 @@ def test_partially_invalid_plot_data(self):
843
861
for kind in kinds :
844
862
self .assertRaises (TypeError , df .plot , kind = kind )
845
863
846
- @slow
847
864
def test_invalid_kind (self ):
848
865
df = DataFrame (np .random .randn (10 , 2 ))
849
866
self .assertRaises (ValueError , df .plot , kind = 'aasdf' )
@@ -880,7 +897,6 @@ def test_boxplot(self):
880
897
_check_plot_works (grouped .boxplot )
881
898
_check_plot_works (grouped .boxplot , subplots = False )
882
899
883
- @slow
884
900
def test_series_plot_color_kwargs (self ):
885
901
# #1890
886
902
import matplotlib .pyplot as plt
@@ -890,7 +906,6 @@ def test_series_plot_color_kwargs(self):
890
906
line = ax .get_lines ()[0 ]
891
907
self .assert_ (line .get_color () == 'green' )
892
908
893
- @slow
894
909
def test_time_series_plot_color_kwargs (self ):
895
910
# #1890
896
911
import matplotlib .pyplot as plt
@@ -901,7 +916,6 @@ def test_time_series_plot_color_kwargs(self):
901
916
line = ax .get_lines ()[0 ]
902
917
self .assert_ (line .get_color () == 'green' )
903
918
904
- @slow
905
919
def test_time_series_plot_color_with_empty_kwargs (self ):
906
920
import matplotlib .pyplot as plt
907
921
@@ -950,6 +964,33 @@ def test_grouped_hist(self):
950
964
self .assertRaises (AttributeError , plotting .grouped_hist , df .A ,
951
965
by = df .C , foo = 'bar' )
952
966
967
+ @slow
968
+ def test_grouped_hist_layout (self ):
969
+ import matplotlib .pyplot as plt
970
+ n = 100
971
+ df = DataFrame ({'gender' : np .array (['Male' ,
972
+ 'Female' ])[random .randint (2 ,
973
+ size = n )],
974
+ 'height' : random .normal (66 , 4 , size = n ),
975
+ 'weight' : random .normal (161 , 32 , size = n ),
976
+ 'category' : random .randint (4 , size = n )})
977
+ self .assertRaises (ValueError , df .hist , column = 'weight' , by = df .gender ,
978
+ layout = (1 , 1 ))
979
+ self .assertRaises (ValueError , df .hist , column = 'weight' , by = df .gender ,
980
+ layout = (1 ,))
981
+ self .assertRaises (ValueError , df .hist , column = 'height' , by = df .category ,
982
+ layout = (1 , 3 ))
983
+ self .assertRaises (ValueError , df .hist , column = 'height' , by = df .category ,
984
+ layout = (2 , 1 ))
985
+ self .assertEqual (df .hist (column = 'height' , by = df .gender ,
986
+ layout = (2 , 1 )).shape , (2 ,))
987
+ plt .close ('all' )
988
+ self .assertEqual (df .hist (column = 'height' , by = df .category ,
989
+ layout = (4 , 1 )).shape , (4 ,))
990
+ plt .close ('all' )
991
+ self .assertEqual (df .hist (column = 'height' , by = df .category ,
992
+ layout = (4 , 2 )).shape , (4 , 2 ))
993
+
953
994
@slow
954
995
def test_axis_shared (self ):
955
996
# GH4089
0 commit comments