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