@@ -138,12 +138,11 @@ def get_title(self, loc="center"):
138138 The title text string.
139139
140140 """
141- try :
142- title = {'left' : self ._left_title ,
143- 'center' : self .title ,
144- 'right' : self ._right_title }[loc .lower ()]
145- except KeyError :
146- raise ValueError ("'%s' is not a valid location" % loc )
141+ titles = {'left' : self ._left_title ,
142+ 'center' : self .title ,
143+ 'right' : self ._right_title }
144+ cbook ._check_in_list (titles , loc = loc .lower ())
145+ title = titles [loc .lower ()]
147146 return title .get_text ()
148147
149148 def set_title (self , label , fontdict = None , loc = None , pad = None ,
@@ -188,15 +187,14 @@ def set_title(self, label, fontdict=None, loc=None, pad=None,
188187 :class:`~matplotlib.text.Text` for a list of valid text
189188 properties.
190189 """
191- try :
192- if loc is None :
193- loc = rcParams ['axes.titlelocation' ]
194-
195- title = {'left' : self ._left_title ,
196- 'center' : self .title ,
197- 'right' : self ._right_title }[loc .lower ()]
198- except KeyError :
199- raise ValueError ("'%s' is not a valid location" % loc )
190+ if loc is None :
191+ loc = rcParams ['axes.titlelocation' ]
192+
193+ titles = {'left' : self ._left_title ,
194+ 'center' : self .title ,
195+ 'right' : self ._right_title }
196+ cbook ._check_in_list (titles , loc = loc .lower ())
197+ title = titles [loc .lower ()]
200198 default = {
201199 'fontsize' : rcParams ['axes.titlesize' ],
202200 'fontweight' : rcParams ['axes.titleweight' ],
@@ -2098,9 +2096,7 @@ def step(self, x, y, *args, where='pre', data=None, **kwargs):
20982096 -----
20992097 .. [notes section required to get data note injection right]
21002098 """
2101- if where not in ('pre' , 'post' , 'mid' ):
2102- raise ValueError ("'where' argument to step must be "
2103- "'pre', 'post' or 'mid'" )
2099+ cbook ._check_in_list (('pre' , 'post' , 'mid' ), where = where )
21042100 kwargs ['drawstyle' ] = 'steps-' + where
21052101 return self .plot (x , y , * args , data = data , ** kwargs )
21062102
@@ -2293,6 +2289,8 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
22932289 error_kw .setdefault ('capsize' , capsize )
22942290
22952291 orientation = kwargs .pop ('orientation' , 'vertical' )
2292+ cbook ._check_in_list (['vertical' , 'horizontal' ],
2293+ orientation = orientation )
22962294 log = kwargs .pop ('log' , False )
22972295 label = kwargs .pop ('label' , '' )
22982296 tick_labels = kwargs .pop ('tick_label' , None )
@@ -2321,8 +2319,6 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
23212319 self ._process_unit_info (xdata = width , ydata = y , kwargs = kwargs )
23222320 if log :
23232321 self .set_xscale ('log' , nonposx = 'clip' )
2324- else :
2325- raise ValueError ('invalid orientation: %s' % orientation )
23262322
23272323 # lets do some conversions now since some types cannot be
23282324 # subtracted uniformly
@@ -2365,6 +2361,7 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
23652361
23662362 # We will now resolve the alignment and really have
23672363 # left, bottom, width, height vectors
2364+ cbook ._check_in_list (['center' , 'edge' ], align = align )
23682365 if align == 'center' :
23692366 if orientation == 'vertical' :
23702367 try :
@@ -2385,8 +2382,6 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
23852382 elif align == 'edge' :
23862383 left = x
23872384 bottom = y
2388- else :
2389- raise ValueError ('invalid alignment: %s' % align )
23902385
23912386 patches = []
23922387 args = zip (left , bottom , width , height , color , edgecolor , linewidth )
0 commit comments