@@ -2243,13 +2243,10 @@ def _convert_dx(dx, x0, xconv, convert):
22432243 except (TypeError , IndexError , KeyError ):
22442244 x = xconv
22452245
2246- delist = False
2247- if not np .iterable (dx ):
2248- dx = [dx ]
2249- delist = True
2250- dx = [convert (x0 + ddx ) - x for ddx in dx ]
2251- if delist :
2252- dx = dx [0 ]
2246+ if np .iterable (dx ):
2247+ dx = [convert (x0 + ddx ) - x for ddx in dx ]
2248+ else :
2249+ dx = convert (x0 + dx ) - x
22532250 except (ValueError , TypeError , AttributeError ):
22542251 # if the above fails (for any reason) just fallback to what
22552252 # we do by default and convert dx by itself.
@@ -3037,15 +3034,21 @@ def broken_barh(self, xranges, yrange, align="bottom", **kwargs):
30373034 [("x" , xdata ), ("y" , ydata )], kwargs , convert = False )
30383035
30393036 vertices = []
3040- y0 , dy = yrange
3037+ ypos , height = yrange
3038+
3039+ # Unit conversion: handling of the difference quantity height is done through
3040+ # _convert_dx() in the same way as width handling in bar().
3041+ y0 = self .convert_yunits (ypos )
3042+ dy = self ._convert_dx (height , ypos , np .array (y0 ), self .convert_yunits )
3043+ print (type (y0 ), type (dy ))
30413044
30423045 _api .check_in_list (['bottom' , 'center' , 'top' ], align = align )
30433046 if align == "bottom" :
3044- y0 , y1 = self . convert_yunits (( y0 , y0 + dy ))
3047+ y1 = y0 + dy
30453048 elif align == "center" :
3046- y0 , y1 = self . convert_yunits (( y0 - dy / 2 , y0 + dy / 2 ))
3049+ y0 , y1 = y0 - dy / 2 , y0 + dy / 2
30473050 else :
3048- y0 , y1 = self . convert_yunits (( y0 - dy , y0 ))
3051+ y0 , y1 = y0 - dy , y0
30493052
30503053 for xr in xranges : # convert the absolute values, not the x and dx
30513054 try :
@@ -3057,6 +3060,7 @@ def broken_barh(self, xranges, yrange, align="bottom", **kwargs):
30573060 x0 , x1 = self .convert_xunits ((x0 , x0 + dx ))
30583061 vertices .append ([(x0 , y0 ), (x0 , y1 ), (x1 , y1 ), (x1 , y0 )])
30593062
3063+ print (vertices )
30603064 col = mcoll .PolyCollection (np .array (vertices ), ** kwargs )
30613065 self .add_collection (col )
30623066
0 commit comments