@@ -3363,6 +3363,40 @@ def test_colors_of_columns_with_same_name(self):
3363
3363
for legend , line in zip (result .get_legend ().legendHandles , result .lines ):
3364
3364
assert legend .get_color () == line .get_color ()
3365
3365
3366
+ @pytest .mark .slow
3367
+ @pytest .mark .parametrize ("method" , ["bar" , "barh" ])
3368
+ def test_bar_ticklabel_consistence (self , method ):
3369
+ # Draw two consecutiv bar plot with consistent ticklabels
3370
+ # GH: 26186
3371
+ def get_main_axis (ax ):
3372
+ if method == "barh" :
3373
+ return ax .yaxis
3374
+ elif method == "bar" :
3375
+ return ax .xaxis
3376
+
3377
+ data = {"A" : 0 , "B" : 3 , "C" : - 4 }
3378
+ df = pd .DataFrame .from_dict (data , orient = "index" , columns = ["Value" ])
3379
+ ax = getattr (df .plot , method )()
3380
+ ax .get_figure ().canvas .draw ()
3381
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3382
+ label_positions_1 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3383
+ df = df .sort_values ("Value" ) * - 2
3384
+ ax = getattr (df .plot , method )(ax = ax , color = "red" )
3385
+ ax .get_figure ().canvas .draw ()
3386
+ xticklabels = [t .get_text () for t in get_main_axis (ax ).get_ticklabels ()]
3387
+ label_positions_2 = dict (zip (xticklabels , get_main_axis (ax ).get_ticklocs ()))
3388
+ assert label_positions_1 == label_positions_2
3389
+
3390
+ def test_bar_numeric (self ):
3391
+ # Bar plot with numeric index have tick location values equal to index
3392
+ # values
3393
+ # GH: 11465
3394
+ index = np .arange (10 , 20 )
3395
+ df = pd .DataFrame (np .random .rand (10 ), index = np .arange (10 , 20 ))
3396
+ ax = df .plot .bar ()
3397
+ ticklocs = ax .xaxis .get_ticklocs ()
3398
+ tm .assert_numpy_array_equal (ticklocs , index )
3399
+
3366
3400
3367
3401
def _generate_4_axes_via_gridspec ():
3368
3402
import matplotlib .pyplot as plt
0 commit comments