File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -2070,10 +2070,9 @@ def make_iterable(x):
2070
2070
2071
2071
if align == 'center' :
2072
2072
if orientation == 'vertical' :
2073
- left = [left [ i ] - width [ i ] / 2. for i in xrange ( len ( left ) )]
2073
+ left = [l - w / 2. for l , w in zip ( left , width )]
2074
2074
elif orientation == 'horizontal' :
2075
- bottom = [bottom [i ] - height [i ] / 2.
2076
- for i in xrange (len (bottom ))]
2075
+ bottom = [b - h / 2. for b , h in zip (bottom , height )]
2077
2076
2078
2077
elif align != 'edge' :
2079
2078
raise ValueError ('invalid alignment: %s' % align )
Original file line number Diff line number Diff line change @@ -4863,6 +4863,36 @@ def test_pandas_indexing_hist():
4863
4863
axes .hist (ser_2 )
4864
4864
4865
4865
4866
+ def test_pandas_bar_align_center ():
4867
+ # Tests fix for issue 8767
4868
+ pd = pytest .importorskip ('pandas' )
4869
+
4870
+ df = pd .DataFrame ({'a' : range (2 ), 'b' : range (2 )})
4871
+
4872
+ fig , ax = plt .subplots (1 )
4873
+
4874
+ rect = ax .bar (df .loc [df ['a' ] == 1 , 'b' ],
4875
+ df .loc [df ['a' ] == 1 , 'b' ],
4876
+ align = 'center' )
4877
+
4878
+ fig .canvas .draw ()
4879
+
4880
+
4881
+ def test_pandas_bar_align_center ():
4882
+ # Tests fix for issue 8767
4883
+ pd = pytest .importorskip ('pandas' )
4884
+
4885
+ df = pd .DataFrame ({'a' : range (2 ), 'b' : range (2 )})
4886
+
4887
+ fig , ax = plt .subplots (1 )
4888
+
4889
+ rect = ax .barh (df .loc [df ['a' ] == 1 , 'b' ],
4890
+ df .loc [df ['a' ] == 1 , 'b' ],
4891
+ align = 'center' )
4892
+
4893
+ fig .canvas .draw ()
4894
+
4895
+
4866
4896
def test_axis_set_tick_params_labelsize_labelcolor ():
4867
4897
# Tests fix for issue 4346
4868
4898
axis_1 = plt .subplot ()
You can’t perform that action at this time.
0 commit comments