@@ -1130,14 +1130,18 @@ def test_bar_categorical(self):
1130
1130
for df in [df1 , df2 ]:
1131
1131
ax = df .plot .bar ()
1132
1132
ticks = ax .xaxis .get_ticklocs ()
1133
- tm .assert_numpy_array_equal (ticks , np .array ([0 , 1 , 2 , 3 , 4 , 5 ]))
1133
+ tm .assert_numpy_array_equal (
1134
+ ticks , np .array ([0 , 1 , 2 , 3 , 4 , 5 ], dtype = np .float )
1135
+ )
1134
1136
assert ax .get_xlim () == (- 0.5 , 5.5 )
1135
1137
# check left-edge of bars
1136
1138
assert ax .patches [0 ].get_x () == - 0.25
1137
1139
assert ax .patches [- 1 ].get_x () == 5.15
1138
1140
1139
1141
ax = df .plot .bar (stacked = True )
1140
- tm .assert_numpy_array_equal (ticks , np .array ([0 , 1 , 2 , 3 , 4 , 5 ]))
1142
+ tm .assert_numpy_array_equal (
1143
+ ticks , np .array ([0 , 1 , 2 , 3 , 4 , 5 ], dtype = np .float )
1144
+ )
1141
1145
assert ax .get_xlim () == (- 0.5 , 5.5 )
1142
1146
assert ax .patches [0 ].get_x () == - 0.25
1143
1147
assert ax .patches [- 1 ].get_x () == 4.75
@@ -3251,30 +3255,27 @@ def test_plot_no_numeric_data(self):
3251
3255
df .plot ()
3252
3256
3253
3257
@pytest .mark .slow
3254
- @pytest .mark .parametrize (' method' , [' bar' , ' barh' ])
3258
+ @pytest .mark .parametrize (" method" , [" bar" , " barh" ])
3255
3259
def test_bar_ticklabel_consistence (self , method ):
3256
3260
# Draw two consecutiv bar plot with consistent ticklabels
3257
3261
# GH: 26186
3258
3262
def get_main_axis (ax ):
3259
- if method == ' barh' :
3263
+ if method == " barh" :
3260
3264
return ax .yaxis
3261
- elif method == ' bar' :
3265
+ elif method == " bar" :
3262
3266
return ax .xaxis
3267
+
3263
3268
data = {"A" : 0 , "B" : 3 , "C" : - 4 }
3264
3269
df = pd .DataFrame .from_dict (data , orient = "index" , columns = ["Value" ])
3265
3270
ax = getattr (df .plot , method )()
3266
3271
ax .get_figure ().canvas .draw ()
3267
- xticklabels = [t .get_text ()
3268
- for t in get_main_axis (ax ).get_ticklabels ()]
3269
- label_positions_1 = dict (zip (xticklabels ,
3270
- get_main_axis (ax ).get_ticklocs ()))
3271
- df = df .sort_values ("Value" ) * - 2
3272
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3273
+ label_positions_1 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3274
+ df = df .sort_values ("Value" ) * - 2
3272
3275
ax = getattr (df .plot , method )(ax = ax , color = "red" )
3273
3276
ax .get_figure ().canvas .draw ()
3274
- xticklabels = [t .get_text ()
3275
- for t in get_main_axis (ax ).get_ticklabels ()]
3276
- label_positions_2 = dict (zip (xticklabels ,
3277
- get_main_axis (ax ).get_ticklocs ()))
3277
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3278
+ label_positions_2 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3278
3279
assert label_positions_1 == label_positions_2
3279
3280
3280
3281
def test_bar_numeric (self ):
0 commit comments