@@ -280,8 +280,11 @@ class LogTransform(Transform):
280280
281281 def __init__ (self , base , nonpos = 'clip' ):
282282 Transform .__init__ (self )
283+ if base <= 0 or base == 1 :
284+ raise ValueError ('The log base cannot be <= 0 or == 1' )
283285 self .base = base
284- self ._clip = {"clip" : True , "mask" : False }[nonpos ]
286+ self ._clip = cbook ._check_getitem (
287+ {"clip" : True , "mask" : False }, nonpos = nonpos )
285288
286289 def __str__ (self ):
287290 return "{}(base={}, nonpos={!r})" .format (
@@ -353,41 +356,28 @@ def __init__(self, axis, **kwargs):
353356 ----------
354357 axis : `~matplotlib.axis.Axis`
355358 The axis for the scale.
356- basex, basey : float, default: 10
359+ base : float, default: 10
357360 The base of the logarithm.
358- nonposx, nonposy : {'clip', 'mask'}, default: 'clip'
361+ nonpos : {'clip', 'mask'}, default: 'clip'
359362 Determines the behavior for non-positive values. They can either
360363 be masked as invalid, or clipped to a very small positive number.
361- subsx, subsy : sequence of int, default: None
362- Where to place the subticks between each major tick.
363- For example, in a log10 scale: ``[2, 3, 4, 5, 6, 7, 8, 9]``
364- will place 8 logarithmically spaced minor ticks between
365- each major tick.
364+ subs : sequence of int, default: None
365+ Where to place the subticks between each major tick. For example,
366+ in a log10 scale, ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place 8
367+ logarithmically spaced minor ticks between each major tick.
366368 """
367- if axis .axis_name == 'x' :
368- base = kwargs .pop ('basex' , 10.0 )
369- subs = kwargs .pop ('subsx' , None )
370- nonpos = kwargs .pop ('nonposx' , 'clip' )
371- cbook ._check_in_list (['mask' , 'clip' ], nonposx = nonpos )
372- else :
373- base = kwargs .pop ('basey' , 10.0 )
374- subs = kwargs .pop ('subsy' , None )
375- nonpos = kwargs .pop ('nonposy' , 'clip' )
376- cbook ._check_in_list (['mask' , 'clip' ], nonposy = nonpos )
377-
378- if kwargs :
379- raise TypeError (f"LogScale got an unexpected keyword "
380- f"argument { next (iter (kwargs ))!r} " )
381-
382- if base <= 0 or base == 1 :
383- raise ValueError ('The log base cannot be <= 0 or == 1' )
384-
369+ axis_name = getattr (axis , "axis_name" , "x" )
370+ @cbook ._rename_parameter ("3.3" , f"base{ axis_name } " , "base" )
371+ @cbook ._rename_parameter ("3.3" , f"subs{ axis_name } " , "subs" )
372+ @cbook ._rename_parameter ("3.3" , f"nonpos{ axis_name } " , "nonpos" )
373+ def __init__ (* , base = 10 , subs = None , nonpos = 'clip' ):
374+ return base , subs , nonpos
375+
376+ base , subs , nonpos = __init__ (** kwargs )
385377 self ._transform = LogTransform (base , nonpos )
386378 self .subs = subs
387379
388- @property
389- def base (self ):
390- return self ._transform .base
380+ base = property (lambda self : self ._transform .base )
391381
392382 def set_default_locators_and_formatters (self , axis ):
393383 # docstring inherited
@@ -455,6 +445,12 @@ class SymmetricalLogTransform(Transform):
455445
456446 def __init__ (self , base , linthresh , linscale ):
457447 Transform .__init__ (self )
448+ if base <= 1.0 :
449+ raise ValueError ("'base' must be larger than 1" )
450+ if linthresh <= 0.0 :
451+ raise ValueError ("'linthresh' must be positive" )
452+ if linscale <= 0.0 :
453+ raise ValueError ("'linscale' must be positive" )
458454 self .base = base
459455 self .linthresh = linthresh
460456 self .linscale = linscale
@@ -515,19 +511,19 @@ class SymmetricalLogScale(ScaleBase):
515511
516512 Parameters
517513 ----------
518- basex, basey : float
514+ base : float
519515 The base of the logarithm. Defaults to 10.
520516
521- linthreshx, linthreshy : float
517+ linthresh : float
522518 Defines the range ``(-x, x)``, within which the plot is linear.
523519 This avoids having the plot go to infinity around zero. Defaults to 2.
524520
525- subsx, subsy : sequence of int
521+ subs : sequence of int
526522 Where to place the subticks between each major tick.
527523 For example, in a log10 scale: ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place
528524 8 logarithmically spaced minor ticks between each major tick.
529525
530- linscalex, linscaley : float, optional
526+ linscale : float, optional
531527 This allows the linear range ``(-linthresh, linthresh)`` to be
532528 stretched relative to the logarithmic range. Its value is the number of
533529 decades to use for each half of the linear range. For example, when
@@ -541,40 +537,30 @@ class SymmetricalLogScale(ScaleBase):
541537 InvertedSymmetricalLogTransform = InvertedSymmetricalLogTransform
542538
543539 def __init__ (self , axis , ** kwargs ):
544- if axis .axis_name == 'x' :
545- base = kwargs .pop ('basex' , 10.0 )
546- linthresh = kwargs .pop ('linthreshx' , 2.0 )
547- subs = kwargs .pop ('subsx' , None )
548- linscale = kwargs .pop ('linscalex' , 1.0 )
549- else :
550- base = kwargs .pop ('basey' , 10.0 )
551- linthresh = kwargs .pop ('linthreshy' , 2.0 )
552- subs = kwargs .pop ('subsy' , None )
553- linscale = kwargs .pop ('linscaley' , 1.0 )
554- if kwargs :
555- warn_deprecated (
556- '3.2.0' ,
557- message = (
558- f"SymmetricalLogScale got an unexpected keyword "
559- f"argument { next (iter (kwargs ))!r} . "
560- 'In the future this will raise TypeError' )
561- )
562- # raise TypeError(f"SymmetricalLogScale got an unexpected keyword "
563- # f"argument {next(iter(kwargs))!r}")
564-
565- if base <= 1.0 :
566- raise ValueError ("'basex/basey' must be larger than 1" )
567- if linthresh <= 0.0 :
568- raise ValueError ("'linthreshx/linthreshy' must be positive" )
569- if linscale <= 0.0 :
570- raise ValueError ("'linscalex/linthreshy' must be positive" )
571-
540+ axis_name = getattr (axis , "axis_name" , "x" )
541+ @cbook ._rename_parameter ("3.3" , f"base{ axis_name } " , "base" )
542+ @cbook ._rename_parameter ("3.3" , f"linthresh{ axis_name } " , "linthresh" )
543+ @cbook ._rename_parameter ("3.3" , f"subs{ axis_name } " , "subs" )
544+ @cbook ._rename_parameter ("3.3" , f"linscale{ axis_name } " , "linscale" )
545+ def __init__ (* , base = 10 , linthresh = 2 , subs = None , linscale = 1 , ** kwargs ):
546+ if kwargs :
547+ warn_deprecated (
548+ "3.2.0" ,
549+ message = (
550+ f"SymmetricalLogScale got an unexpected keyword "
551+ f"argument { next (iter (kwargs ))!r} ; in the future, "
552+ f"this will raise a TypeError" )
553+ )
554+ return base , linthresh , subs , linscale
555+
556+ base , linthresh , subs , linscale = __init__ (** kwargs )
572557 self ._transform = SymmetricalLogTransform (base , linthresh , linscale )
573- self .base = base
574- self .linthresh = linthresh
575- self .linscale = linscale
576558 self .subs = subs
577559
560+ base = property (lambda self : self ._transform .base )
561+ linthresh = property (lambda self : self ._transform .linthresh )
562+ linscale = property (lambda self : self ._transform .linscale )
563+
578564 def set_default_locators_and_formatters (self , axis ):
579565 # docstring inherited
580566 axis .set_major_locator (SymmetricalLogLocator (self .get_transform ()))
0 commit comments