@@ -2100,6 +2100,32 @@ def test_bar_nan(self):
2100
2100
expected = [0.0 , 0.0 , 0.0 , 10.0 , 0.0 , 20.0 , 15.0 , 10.0 , 40.0 ]
2101
2101
self .assertEqual (result , expected )
2102
2102
2103
+ @slow
2104
+ def test_bar_categorical (self ):
2105
+ # GH 13019
2106
+ df1 = pd .DataFrame (np .random .randn (6 , 5 ),
2107
+ index = pd .Index (list ('ABCDEF' )),
2108
+ columns = pd .Index (list ('abcde' )))
2109
+ # categorical index must behave the same
2110
+ df2 = pd .DataFrame (np .random .randn (6 , 5 ),
2111
+ index = pd .CategoricalIndex (list ('ABCDEF' )),
2112
+ columns = pd .CategoricalIndex (list ('abcde' )))
2113
+
2114
+ for df in [df1 , df2 ]:
2115
+ ax = df .plot .bar ()
2116
+ ticks = ax .xaxis .get_ticklocs ()
2117
+ tm .assert_numpy_array_equal (ticks , np .array ([0 , 1 , 2 , 3 , 4 , 5 ]))
2118
+ self .assertEqual (ax .get_xlim (), (- 0.5 , 5.5 ))
2119
+ # check left-edge of bars
2120
+ self .assertEqual (ax .patches [0 ].get_x (), - 0.25 )
2121
+ self .assertEqual (ax .patches [- 1 ].get_x (), 5.15 )
2122
+
2123
+ ax = df .plot .bar (stacked = True )
2124
+ tm .assert_numpy_array_equal (ticks , np .array ([0 , 1 , 2 , 3 , 4 , 5 ]))
2125
+ self .assertEqual (ax .get_xlim (), (- 0.5 , 5.5 ))
2126
+ self .assertEqual (ax .patches [0 ].get_x (), - 0.25 )
2127
+ self .assertEqual (ax .patches [- 1 ].get_x (), 4.75 )
2128
+
2103
2129
@slow
2104
2130
def test_plot_scatter (self ):
2105
2131
df = DataFrame (randn (6 , 4 ),
0 commit comments