@@ -5737,3 +5737,125 @@ def test_share_symmetric1():
5737
5737
assert _symmetric (A , B , ax )
5738
5738
5739
5739
plt .close (fig )
5740
+
5741
+
5742
+ def test_unshare_axes ():
5743
+ axes = ["x" , "y" ]
5744
+
5745
+ for ax in axes :
5746
+ fig = plt .figure ()
5747
+ A = fig .add_subplot (511 )
5748
+ B = fig .add_subplot (512 )
5749
+ C = fig .add_subplot (513 )
5750
+ D = fig .add_subplot (514 )
5751
+ E = fig .add_subplot (515 )
5752
+
5753
+ # E -> A
5754
+ share = getattr (E , "share_{}_axes" .format (ax ))
5755
+ share (A , symmetric = False , transitive = False )
5756
+
5757
+ # C -> D
5758
+ share = getattr (C , "share_{}_axes" .format (ax ))
5759
+ share (D , symmetric = False , transitive = False )
5760
+
5761
+ # A -> B
5762
+ share = getattr (A , "share_{}_axes" .format (ax ))
5763
+ share (B , symmetric = False , transitive = False )
5764
+
5765
+ # A -> C, A -> D
5766
+ share (C , symmetric = False , transitive = True )
5767
+
5768
+ unshare = getattr (A , "unshare_{}_axes" .format (ax ))
5769
+ unshare (None )
5770
+
5771
+ assert _asymmetric (C , D , ax )
5772
+ assert _no_relation (A , B , ax )
5773
+ assert _no_relation (A , C , ax )
5774
+ assert _no_relation (A , D , ax )
5775
+ assert _no_relation (A , E , ax )
5776
+
5777
+ assert _no_relation (B , C , ax )
5778
+ assert _no_relation (B , E , ax )
5779
+ assert _no_relation (B , D , ax )
5780
+
5781
+ assert _no_relation (E , B , ax )
5782
+ assert _no_relation (E , C , ax )
5783
+ assert _no_relation (E , D , ax )
5784
+
5785
+
5786
+ def test_unshare_axes1 ():
5787
+ axes = ["x" , "y" ]
5788
+
5789
+ for ax in axes :
5790
+ fig = plt .figure ()
5791
+ A = fig .add_subplot (511 )
5792
+ B = fig .add_subplot (512 )
5793
+ C = fig .add_subplot (513 )
5794
+ D = fig .add_subplot (514 )
5795
+ E = fig .add_subplot (515 )
5796
+
5797
+ # E -> A
5798
+ share = getattr (E , "share_{}_axes" .format (ax ))
5799
+ share (A , symmetric = False , transitive = False )
5800
+
5801
+ # C -> D
5802
+ share = getattr (C , "share_{}_axes" .format (ax ))
5803
+ share (D , symmetric = False , transitive = False )
5804
+
5805
+ # A -> B
5806
+ share = getattr (A , "share_{}_axes" .format (ax ))
5807
+ share (B , symmetric = False , transitive = False )
5808
+
5809
+ # A -> C, A -> D
5810
+ share (C , symmetric = False , transitive = True )
5811
+
5812
+ unshare = getattr (A , "unshare_{}_axes" .format (ax ))
5813
+ unshare (A )
5814
+
5815
+ assert _asymmetric (C , D , ax )
5816
+ assert _asymmetric (A , B , ax )
5817
+ assert _asymmetric (A , C , ax )
5818
+ assert _asymmetric (A , D , ax )
5819
+ assert _no_relation (A , E , ax )
5820
+ assert _no_relation (E , C , ax )
5821
+ assert _no_relation (E , D , ax )
5822
+ assert _no_relation (B , D , ax )
5823
+
5824
+
5825
+ def test_unshare_axes2 ():
5826
+ axes = ["x" , "y" ]
5827
+
5828
+ for ax in axes :
5829
+ fig = plt .figure ()
5830
+ A = fig .add_subplot (511 )
5831
+ B = fig .add_subplot (512 )
5832
+ C = fig .add_subplot (513 )
5833
+ D = fig .add_subplot (514 )
5834
+ E = fig .add_subplot (515 )
5835
+
5836
+ # E -> A
5837
+ share = getattr (E , "share_{}_axes" .format (ax ))
5838
+ share (A , symmetric = False , transitive = False )
5839
+
5840
+ # C -> D
5841
+ share = getattr (C , "share_{}_axes" .format (ax ))
5842
+ share (D , symmetric = False , transitive = False )
5843
+
5844
+ # A -> B
5845
+ share = getattr (A , "share_{}_axes" .format (ax ))
5846
+ share (B , symmetric = False , transitive = False )
5847
+
5848
+ # A -> C, A -> D
5849
+ share (C , symmetric = False , transitive = True )
5850
+
5851
+ unshare = getattr (A , "unshare_{}_axes" .format (ax ))
5852
+ unshare (C )
5853
+
5854
+ assert _asymmetric (C , D , ax )
5855
+ assert _asymmetric (A , B , ax )
5856
+ assert _no_relation (A , C , ax )
5857
+ assert _asymmetric (A , D , ax )
5858
+ assert _asymmetric (E , A , ax )
5859
+ assert _no_relation (E , C , ax )
5860
+ assert _no_relation (E , D , ax )
5861
+ assert _no_relation (B , D , ax )
0 commit comments