@@ -3316,6 +3316,40 @@ def test_missing_markers_legend_using_style(self):
3316
3316
self ._check_legend_labels (ax , labels = ["A" , "B" , "C" ])
3317
3317
self ._check_legend_marker (ax , expected_markers = ["." , "." , "." ])
3318
3318
3319
+ @pytest .mark .slow
3320
+ @pytest .mark .parametrize ("method" , ["bar" , "barh" ])
3321
+ def test_bar_ticklabel_consistence (self , method ):
3322
+ # Draw two consecutiv bar plot with consistent ticklabels
3323
+ # GH: 26186
3324
+ def get_main_axis (ax ):
3325
+ if method == "barh" :
3326
+ return ax .yaxis
3327
+ elif method == "bar" :
3328
+ return ax .xaxis
3329
+
3330
+ data = {"A" : 0 , "B" : 3 , "C" : - 4 }
3331
+ df = pd .DataFrame .from_dict (data , orient = "index" , columns = ["Value" ])
3332
+ ax = getattr (df .plot , method )()
3333
+ ax .get_figure ().canvas .draw ()
3334
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3335
+ label_positions_1 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3336
+ df = df .sort_values ("Value" ) * - 2
3337
+ ax = getattr (df .plot , method )(ax = ax , color = "red" )
3338
+ ax .get_figure ().canvas .draw ()
3339
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3340
+ label_positions_2 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3341
+ assert label_positions_1 == label_positions_2
3342
+
3343
+ def test_bar_numeric (self ):
3344
+ # Bar plot with numeric index have tick location values equal to index
3345
+ # values
3346
+ # GH: 11465
3347
+ index = np .arange (10 , 20 )
3348
+ df = pd .DataFrame (np .random .rand (10 ), index = np .arange (10 , 20 ))
3349
+ ax = df .plot .bar ()
3350
+ ticklocs = ax .xaxis .get_ticklocs ()
3351
+ tm .assert_numpy_array_equal (ticklocs , index )
3352
+
3319
3353
3320
3354
def _generate_4_axes_via_gridspec ():
3321
3355
import matplotlib .pyplot as plt
0 commit comments