@@ -582,14 +582,17 @@ def invert(x):
582
582
secax.set_xlabel('Period [s]')
583
583
plt.show()
584
584
"""
585
- if location in ['top' , 'bottom' ] or isinstance (location , Real ):
586
- secondary_ax = SecondaryAxis (self , 'x' , location , functions ,
587
- transform , ** kwargs )
588
- self .add_child_axes (secondary_ax )
589
- return secondary_ax
590
- else :
585
+ if not (location in ['top' , 'bottom' ] or isinstance (location , Real )):
591
586
raise ValueError ('secondary_xaxis location must be either '
592
587
'a float or "top"/"bottom"' )
588
+ if not (isinstance (transform , mtransforms .Transform ) or transform is None ):
589
+ raise ValueError ('transform must be either an mtransforms.Transform '
590
+ 'or None' )
591
+
592
+ secondary_ax = SecondaryAxis (self , 'x' , location , functions ,
593
+ transform , ** kwargs )
594
+ self .add_child_axes (secondary_ax )
595
+ return secondary_ax
593
596
594
597
@_docstring .dedent_interpd
595
598
def secondary_yaxis (self , location , * , functions = None , transform = None , ** kwargs ):
@@ -614,14 +617,16 @@ def secondary_yaxis(self, location, *, functions=None, transform=None, **kwargs)
614
617
np.rad2deg))
615
618
secax.set_ylabel('radians')
616
619
"""
617
- if location in ['left' , 'right' ] or isinstance (location , Real ):
618
- secondary_ax = SecondaryAxis (self , 'y' , location , functions ,
619
- transform , ** kwargs )
620
- self .add_child_axes (secondary_ax )
621
- return secondary_ax
622
- else :
623
- raise ValueError ('secondary_yaxis location must be either '
620
+ if not (location in ['left' , 'right' ] or isinstance (location , Real )):
621
+ raise ValueError ('secondary_xaxis location must be either '
624
622
'a float or "left"/"right"' )
623
+ if not (isinstance (transform , mtransforms .Transform ) or transform is None ):
624
+ raise ValueError ('transform must be either an mtransforms.Transform '
625
+ 'or None' )
626
+ secondary_ax = SecondaryAxis (self , 'y' , location , functions ,
627
+ transform , ** kwargs )
628
+ self .add_child_axes (secondary_ax )
629
+ return secondary_ax
625
630
626
631
@_docstring .dedent_interpd
627
632
def text (self , x , y , s , fontdict = None , ** kwargs ):
0 commit comments