@@ -1814,25 +1814,19 @@ def step(self, x, y, *args, **kwargs):
1814
1814
replace_all_args = True
1815
1815
)
1816
1816
@docstring .dedent_interpd
1817
- def bar (self , * args , ** kwargs ):
1817
+ def bar (self , x , height , width = 0.8 , bottom = None , * , align = "center" ,
1818
+ ** kwargs ):
1818
1819
r"""
1819
1820
Make a bar plot.
1820
1821
1821
- Call signatures::
1822
-
1823
- bar(x, height, *, align='center', **kwargs)
1824
- bar(x, height, width, *, align='center', **kwargs)
1825
- bar(x, height, width, bottom, *, align='center', **kwargs)
1826
-
1827
- The bars are positioned at *x* with the given *align* ment. Their
1822
+ The bars are positioned at *x* with the given *align*\ment. Their
1828
1823
dimensions are given by *width* and *height*. The vertical baseline
1829
1824
is *bottom* (default 0).
1830
1825
1831
1826
Each of *x*, *height*, *width*, and *bottom* may either be a scalar
1832
1827
applying to all bars, or it may be a sequence of length N providing a
1833
1828
separate value for each bar.
1834
1829
1835
-
1836
1830
Parameters
1837
1831
----------
1838
1832
x : sequence of scalars
@@ -1927,33 +1921,6 @@ def bar(self, *args, **kwargs):
1927
1921
1928
1922
"""
1929
1923
kwargs = cbook .normalize_kwargs (kwargs , mpatches .Patch ._alias_map )
1930
- # this is using the lambdas to do the arg/kwarg unpacking rather
1931
- # than trying to re-implement all of that logic our selves.
1932
- matchers = [
1933
- (lambda x , height , width = 0.8 , bottom = None , ** kwargs :
1934
- (False , x , height , width , bottom , kwargs )),
1935
- (lambda left , height , width = 0.8 , bottom = None , ** kwargs :
1936
- (True , left , height , width , bottom , kwargs )),
1937
- ]
1938
- exps = []
1939
- for matcher in matchers :
1940
- try :
1941
- dp , x , height , width , y , kwargs = matcher (* args , ** kwargs )
1942
- except TypeError as e :
1943
- # This can only come from a no-match as there is
1944
- # no other logic in the matchers.
1945
- exps .append (e )
1946
- else :
1947
- break
1948
- else :
1949
- raise exps [0 ]
1950
- # if we matched the second-case, then the user passed in
1951
- # left=val as a kwarg which we want to deprecate
1952
- if dp :
1953
- warnings .warn (
1954
- "The *left* kwarg to `bar` is deprecated use *x* instead. "
1955
- "Support for *left* will be removed in Matplotlib 3.0" ,
1956
- mplDeprecation , stacklevel = 2 )
1957
1924
color = kwargs .pop ('color' , None )
1958
1925
if color is None :
1959
1926
color = self ._get_patches_for_fill .get_next_color ()
@@ -1965,17 +1932,12 @@ def bar(self, *args, **kwargs):
1965
1932
# to the errorbar method.
1966
1933
xerr = kwargs .pop ('xerr' , None )
1967
1934
yerr = kwargs .pop ('yerr' , None )
1968
- error_kw = kwargs .pop ('error_kw' , dict () )
1935
+ error_kw = kwargs .pop ('error_kw' , {} )
1969
1936
ecolor = kwargs .pop ('ecolor' , 'k' )
1970
1937
capsize = kwargs .pop ('capsize' , rcParams ["errorbar.capsize" ])
1971
1938
error_kw .setdefault ('ecolor' , ecolor )
1972
1939
error_kw .setdefault ('capsize' , capsize )
1973
1940
1974
- if rcParams ['_internal.classic_mode' ]:
1975
- align = kwargs .pop ('align' , 'edge' )
1976
- else :
1977
- align = kwargs .pop ('align' , 'center' )
1978
-
1979
1941
orientation = kwargs .pop ('orientation' , 'vertical' )
1980
1942
log = kwargs .pop ('log' , False )
1981
1943
label = kwargs .pop ('label' , '' )
@@ -1984,8 +1946,9 @@ def bar(self, *args, **kwargs):
1984
1946
adjust_ylim = False
1985
1947
adjust_xlim = False
1986
1948
1949
+ y = bottom # Matches barh call signature.
1987
1950
if orientation == 'vertical' :
1988
- if y is None :
1951
+ if bottom is None :
1989
1952
if self .get_yscale () == 'log' :
1990
1953
adjust_ylim = True
1991
1954
y = 0
@@ -2126,25 +2089,19 @@ def bar(self, *args, **kwargs):
2126
2089
return bar_container
2127
2090
2128
2091
@docstring .dedent_interpd
2129
- def barh (self , * args , ** kwargs ):
2092
+ def barh (self , y , width , height = 0.8 , left = None , * , align = "center" ,
2093
+ ** kwargs ):
2130
2094
r"""
2131
2095
Make a horizontal bar plot.
2132
2096
2133
- Call signatures::
2134
-
2135
- bar(y, width, *, align='center', **kwargs)
2136
- bar(y, width, height, *, align='center', **kwargs)
2137
- bar(y, width, height, left, *, align='center', **kwargs)
2138
-
2139
- The bars are positioned at *y* with the given *align*. Their
2097
+ The bars are positioned at *y* with the given *align*\ment. Their
2140
2098
dimensions are given by *width* and *height*. The horizontal baseline
2141
2099
is *left* (default 0).
2142
2100
2143
2101
Each of *y*, *width*, *height*, and *left* may either be a scalar
2144
2102
applying to all bars, or it may be a sequence of length N providing a
2145
2103
separate value for each bar.
2146
2104
2147
-
2148
2105
Parameters
2149
2106
----------
2150
2107
y : scalar or array-like
@@ -2235,35 +2192,9 @@ def barh(self, *args, **kwargs):
2235
2192
%(Rectangle)s
2236
2193
2237
2194
"""
2238
- # this is using the lambdas to do the arg/kwarg unpacking rather
2239
- # than trying to re-implement all of that logic our selves.
2240
- matchers = [
2241
- (lambda y , width , height = 0.8 , left = None , ** kwargs :
2242
- (False , y , width , height , left , kwargs )),
2243
- (lambda bottom , width , height = 0.8 , left = None , ** kwargs :
2244
- (True , bottom , width , height , left , kwargs )),
2245
- ]
2246
- excs = []
2247
- for matcher in matchers :
2248
- try :
2249
- dp , y , width , height , left , kwargs = matcher (* args , ** kwargs )
2250
- except TypeError as e :
2251
- # This can only come from a no-match as there is
2252
- # no other logic in the matchers.
2253
- excs .append (e )
2254
- else :
2255
- break
2256
- else :
2257
- raise excs [0 ]
2258
-
2259
- if dp :
2260
- warnings .warn (
2261
- "The *bottom* kwarg to `barh` is deprecated use *y* instead. "
2262
- "Support for *bottom* will be removed in Matplotlib 3.0" ,
2263
- mplDeprecation , stacklevel = 2 )
2264
2195
kwargs .setdefault ('orientation' , 'horizontal' )
2265
- patches = self .bar (x = left , height = height , width = width ,
2266
- bottom = y , ** kwargs )
2196
+ patches = self .bar (x = left , height = height , width = width , bottom = y ,
2197
+ align = align , ** kwargs )
2267
2198
return patches
2268
2199
2269
2200
@_preprocess_data (label_namer = None )
0 commit comments