@@ -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
@@ -454,6 +444,12 @@ class SymmetricalLogTransform(Transform):
454444
455445 def __init__ (self , base , linthresh , linscale ):
456446 Transform .__init__ (self )
447+ if base <= 1.0 :
448+ raise ValueError ("'base' must be larger than 1" )
449+ if linthresh <= 0.0 :
450+ raise ValueError ("'linthresh' must be positive" )
451+ if linscale <= 0.0 :
452+ raise ValueError ("'linscale' must be positive" )
457453 self .base = base
458454 self .linthresh = linthresh
459455 self .linscale = linscale
@@ -514,19 +510,19 @@ class SymmetricalLogScale(ScaleBase):
514510
515511 Parameters
516512 ----------
517- basex, basey : float, default: 10
513+ base : float, default: 10
518514 The base of the logarithm.
519515
520- linthreshx, linthreshy : float, default: 2
516+ linthresh : float, default: 2
521517 Defines the range ``(-x, x)``, within which the plot is linear.
522518 This avoids having the plot go to infinity around zero.
523519
524- subsx, subsy : sequence of int
520+ subs : sequence of int
525521 Where to place the subticks between each major tick.
526522 For example, in a log10 scale: ``[2, 3, 4, 5, 6, 7, 8, 9]`` will place
527523 8 logarithmically spaced minor ticks between each major tick.
528524
529- linscalex, linscaley : float, optional
525+ linscale : float, optional
530526 This allows the linear range ``(-linthresh, linthresh)`` to be
531527 stretched relative to the logarithmic range. Its value is the number of
532528 decades to use for each half of the linear range. For example, when
@@ -540,40 +536,30 @@ class SymmetricalLogScale(ScaleBase):
540536 InvertedSymmetricalLogTransform = InvertedSymmetricalLogTransform
541537
542538 def __init__ (self , axis , ** kwargs ):
543- if axis .axis_name == 'x' :
544- base = kwargs .pop ('basex' , 10.0 )
545- linthresh = kwargs .pop ('linthreshx' , 2.0 )
546- subs = kwargs .pop ('subsx' , None )
547- linscale = kwargs .pop ('linscalex' , 1.0 )
548- else :
549- base = kwargs .pop ('basey' , 10.0 )
550- linthresh = kwargs .pop ('linthreshy' , 2.0 )
551- subs = kwargs .pop ('subsy' , None )
552- linscale = kwargs .pop ('linscaley' , 1.0 )
553- if kwargs :
554- warn_deprecated (
555- '3.2.0' ,
556- message = (
557- f"SymmetricalLogScale got an unexpected keyword "
558- f"argument { next (iter (kwargs ))!r} . "
559- 'In the future this will raise TypeError' )
560- )
561- # raise TypeError(f"SymmetricalLogScale got an unexpected keyword "
562- # f"argument {next(iter(kwargs))!r}")
563-
564- if base <= 1.0 :
565- raise ValueError ("'basex/basey' must be larger than 1" )
566- if linthresh <= 0.0 :
567- raise ValueError ("'linthreshx/linthreshy' must be positive" )
568- if linscale <= 0.0 :
569- raise ValueError ("'linscalex/linthreshy' must be positive" )
570-
539+ axis_name = getattr (axis , "axis_name" , "x" )
540+ @cbook ._rename_parameter ("3.3" , f"base{ axis_name } " , "base" )
541+ @cbook ._rename_parameter ("3.3" , f"linthresh{ axis_name } " , "linthresh" )
542+ @cbook ._rename_parameter ("3.3" , f"subs{ axis_name } " , "subs" )
543+ @cbook ._rename_parameter ("3.3" , f"linscale{ axis_name } " , "linscale" )
544+ def __init__ (* , base = 10 , linthresh = 2 , subs = None , linscale = 1 , ** kwargs ):
545+ if kwargs :
546+ warn_deprecated (
547+ "3.2.0" ,
548+ message = (
549+ f"SymmetricalLogScale got an unexpected keyword "
550+ f"argument { next (iter (kwargs ))!r} ; in the future, "
551+ f"this will raise a TypeError" )
552+ )
553+ return base , linthresh , subs , linscale
554+
555+ base , linthresh , subs , linscale = __init__ (** kwargs )
571556 self ._transform = SymmetricalLogTransform (base , linthresh , linscale )
572- self .base = base
573- self .linthresh = linthresh
574- self .linscale = linscale
575557 self .subs = subs
576558
559+ base = property (lambda self : self ._transform .base )
560+ linthresh = property (lambda self : self ._transform .linthresh )
561+ linscale = property (lambda self : self ._transform .linscale )
562+
577563 def set_default_locators_and_formatters (self , axis ):
578564 # docstring inherited
579565 axis .set_major_locator (SymmetricalLogLocator (self .get_transform ()))
0 commit comments