@@ -3440,6 +3440,40 @@ def test_xlabel_ylabel_dataframe_subplots(
3440
3440
assert all (ax .get_ylabel () == str (new_label ) for ax in axes )
3441
3441
assert all (ax .get_xlabel () == str (new_label ) for ax in axes )
3442
3442
3443
+ @pytest .mark .slow
3444
+ @pytest .mark .parametrize ("method" , ["bar" , "barh" ])
3445
+ def test_bar_ticklabel_consistence (self , method ):
3446
+ # Draw two consecutiv bar plot with consistent ticklabels
3447
+ # GH: 26186
3448
+ def get_main_axis (ax ):
3449
+ if method == "barh" :
3450
+ return ax .yaxis
3451
+ elif method == "bar" :
3452
+ return ax .xaxis
3453
+
3454
+ data = {"A" : 0 , "B" : 3 , "C" : - 4 }
3455
+ df = pd .DataFrame .from_dict (data , orient = "index" , columns = ["Value" ])
3456
+ ax = getattr (df .plot , method )()
3457
+ ax .get_figure ().canvas .draw ()
3458
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3459
+ label_positions_1 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3460
+ df = df .sort_values ("Value" ) * - 2
3461
+ ax = getattr (df .plot , method )(ax = ax , color = "red" )
3462
+ ax .get_figure ().canvas .draw ()
3463
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3464
+ label_positions_2 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3465
+ assert label_positions_1 == label_positions_2
3466
+
3467
+ def test_bar_numeric (self ):
3468
+ # Bar plot with numeric index have tick location values equal to index
3469
+ # values
3470
+ # GH: 11465
3471
+ index = np .arange (10 , 20 )
3472
+ df = pd .DataFrame (np .random .rand (10 ), index = np .arange (10 , 20 ))
3473
+ ax = df .plot .bar ()
3474
+ ticklocs = ax .xaxis .get_ticklocs ()
3475
+ tm .assert_numpy_array_equal (ticklocs , index )
3476
+
3443
3477
3444
3478
def _generate_4_axes_via_gridspec ():
3445
3479
import matplotlib as mpl
0 commit comments