@@ -1814,25 +1814,19 @@ def step(self, x, y, *args, **kwargs):
18141814 replace_all_args = True
18151815 )
18161816 @docstring .dedent_interpd
1817- def bar (self , * args , ** kwargs ):
1817+ def bar (self , x , height , width = 0.8 , bottom = None , * , align = "center" ,
1818+ ** kwargs ):
18181819 r"""
18191820 Make a bar plot.
18201821
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
18281823 dimensions are given by *width* and *height*. The vertical baseline
18291824 is *bottom* (default 0).
18301825
18311826 Each of *x*, *height*, *width*, and *bottom* may either be a scalar
18321827 applying to all bars, or it may be a sequence of length N providing a
18331828 separate value for each bar.
18341829
1835-
18361830 Parameters
18371831 ----------
18381832 x : sequence of scalars
@@ -1927,55 +1921,22 @@ def bar(self, *args, **kwargs):
19271921
19281922 """
19291923 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 )
19571924 color = kwargs .pop ('color' , None )
19581925 if color is None :
19591926 color = self ._get_patches_for_fill .get_next_color ()
19601927 edgecolor = kwargs .pop ('edgecolor' , None )
19611928 linewidth = kwargs .pop ('linewidth' , None )
19621929
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.
19661932 xerr = kwargs .pop ('xerr' , None )
19671933 yerr = kwargs .pop ('yerr' , None )
1968- error_kw = kwargs .pop ('error_kw' , dict () )
1934+ error_kw = kwargs .pop ('error_kw' , {} )
19691935 ecolor = kwargs .pop ('ecolor' , 'k' )
19701936 capsize = kwargs .pop ('capsize' , rcParams ["errorbar.capsize" ])
19711937 error_kw .setdefault ('ecolor' , ecolor )
19721938 error_kw .setdefault ('capsize' , capsize )
19731939
1974- if rcParams ['_internal.classic_mode' ]:
1975- align = kwargs .pop ('align' , 'edge' )
1976- else :
1977- align = kwargs .pop ('align' , 'center' )
1978-
19791940 orientation = kwargs .pop ('orientation' , 'vertical' )
19801941 log = kwargs .pop ('log' , False )
19811942 label = kwargs .pop ('label' , '' )
@@ -1984,8 +1945,9 @@ def bar(self, *args, **kwargs):
19841945 adjust_ylim = False
19851946 adjust_xlim = False
19861947
1948+ y = bottom # Matches barh call signature.
19871949 if orientation == 'vertical' :
1988- if y is None :
1950+ if bottom is None :
19891951 if self .get_yscale () == 'log' :
19901952 adjust_ylim = True
19911953 y = 0
@@ -2126,25 +2088,19 @@ def bar(self, *args, **kwargs):
21262088 return bar_container
21272089
21282090 @docstring .dedent_interpd
2129- def barh (self , * args , ** kwargs ):
2091+ def barh (self , y , width , height = 0.8 , left = None , * , align = "center" ,
2092+ ** kwargs ):
21302093 r"""
21312094 Make a horizontal bar plot.
21322095
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
21402097 dimensions are given by *width* and *height*. The horizontal baseline
21412098 is *left* (default 0).
21422099
21432100 Each of *y*, *width*, *height*, and *left* may either be a scalar
21442101 applying to all bars, or it may be a sequence of length N providing a
21452102 separate value for each bar.
21462103
2147-
21482104 Parameters
21492105 ----------
21502106 y : scalar or array-like
@@ -2235,35 +2191,9 @@ def barh(self, *args, **kwargs):
22352191 %(Rectangle)s
22362192
22372193 """
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 )
22642194 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 )
22672197 return patches
22682198
22692199 @_preprocess_data (label_namer = None )
0 commit comments