@@ -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,55 +1921,22 @@ 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 ()
1960
1927
edgecolor = kwargs .pop ('edgecolor' , None )
1961
1928
linewidth = kwargs .pop ('linewidth' , None )
1962
1929
1963
- # Because xerr and yerr will be passed to errorbar,
1964
- # most dimension checking and processing will be left
1965
- # to the errorbar method.
1930
+ # Because xerr and yerr will be passed to errorbar, most dimension
1931
+ # checking and processing will be left to the errorbar method.
1966
1932
xerr = kwargs .pop ('xerr' , None )
1967
1933
yerr = kwargs .pop ('yerr' , None )
1968
- error_kw = kwargs .pop ('error_kw' , dict () )
1934
+ error_kw = kwargs .pop ('error_kw' , {} )
1969
1935
ecolor = kwargs .pop ('ecolor' , 'k' )
1970
1936
capsize = kwargs .pop ('capsize' , rcParams ["errorbar.capsize" ])
1971
1937
error_kw .setdefault ('ecolor' , ecolor )
1972
1938
error_kw .setdefault ('capsize' , capsize )
1973
1939
1974
- if rcParams ['_internal.classic_mode' ]:
1975
- align = kwargs .pop ('align' , 'edge' )
1976
- else :
1977
- align = kwargs .pop ('align' , 'center' )
1978
-
1979
1940
orientation = kwargs .pop ('orientation' , 'vertical' )
1980
1941
log = kwargs .pop ('log' , False )
1981
1942
label = kwargs .pop ('label' , '' )
@@ -1984,8 +1945,9 @@ def bar(self, *args, **kwargs):
1984
1945
adjust_ylim = False
1985
1946
adjust_xlim = False
1986
1947
1948
+ y = bottom # Matches barh call signature.
1987
1949
if orientation == 'vertical' :
1988
- if y is None :
1950
+ if bottom is None :
1989
1951
if self .get_yscale () == 'log' :
1990
1952
adjust_ylim = True
1991
1953
y = 0
@@ -2126,25 +2088,19 @@ def bar(self, *args, **kwargs):
2126
2088
return bar_container
2127
2089
2128
2090
@docstring .dedent_interpd
2129
- def barh (self , * args , ** kwargs ):
2091
+ def barh (self , y , width , height = 0.8 , left = None , * , align = "center" ,
2092
+ ** kwargs ):
2130
2093
r"""
2131
2094
Make a horizontal bar plot.
2132
2095
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
2096
+ The bars are positioned at *y* with the given *align*\ment. Their
2140
2097
dimensions are given by *width* and *height*. The horizontal baseline
2141
2098
is *left* (default 0).
2142
2099
2143
2100
Each of *y*, *width*, *height*, and *left* may either be a scalar
2144
2101
applying to all bars, or it may be a sequence of length N providing a
2145
2102
separate value for each bar.
2146
2103
2147
-
2148
2104
Parameters
2149
2105
----------
2150
2106
y : scalar or array-like
@@ -2235,35 +2191,9 @@ def barh(self, *args, **kwargs):
2235
2191
%(Rectangle)s
2236
2192
2237
2193
"""
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
2194
kwargs .setdefault ('orientation' , 'horizontal' )
2265
- patches = self .bar (x = left , height = height , width = width ,
2266
- bottom = y , ** kwargs )
2195
+ patches = self .bar (x = left , height = height , width = width , bottom = y ,
2196
+ align = align , ** kwargs )
2267
2197
return patches
2268
2198
2269
2199
@_preprocess_data (label_namer = None )
0 commit comments