@@ -937,134 +937,3 @@ def test_subfigure_double():
937937 subfigsnest [1 ].supylabel ('supylabel' )
938938
939939 axsRight = subfigs [1 ].subplots (2 , 2 )
940-
941-
942- def test_axes_kwargs ():
943- # plt.axes() always creates new axes, even if axes kwargs differ.
944- plt .figure ()
945- ax = plt .axes ()
946- ax1 = plt .axes ()
947- assert ax is not None
948- assert ax1 is not ax
949- plt .close ()
950-
951- plt .figure ()
952- ax = plt .axes (projection = 'polar' )
953- ax1 = plt .axes (projection = 'polar' )
954- assert ax is not None
955- assert ax1 is not ax
956- plt .close ()
957-
958- plt .figure ()
959- ax = plt .axes (projection = 'polar' )
960- ax1 = plt .axes ()
961- assert ax is not None
962- assert ax1 .name == 'rectilinear'
963- assert ax1 is not ax
964- plt .close ()
965-
966- # fig.add_axes() always creates new axes, even if axes kwargs differ.
967- fig = plt .figure ()
968- ax = fig .add_axes ([0 , 0 , 1 , 1 ])
969- ax1 = fig .add_axes ([0 , 0 , 1 , 1 ])
970- assert ax is not None
971- assert ax1 is not ax
972- plt .close ()
973-
974- fig = plt .figure ()
975- ax = fig .add_axes ([0 , 0 , 1 , 1 ], projection = 'polar' )
976- ax1 = fig .add_axes ([0 , 0 , 1 , 1 ], projection = 'polar' )
977- assert ax is not None
978- assert ax1 is not ax
979- plt .close ()
980-
981- fig = plt .figure ()
982- ax = fig .add_axes ([0 , 0 , 1 , 1 ], projection = 'polar' )
983- ax1 = fig .add_axes ([0 , 0 , 1 , 1 ])
984- assert ax is not None
985- assert ax1 .name == 'rectilinear'
986- assert ax1 is not ax
987- plt .close ()
988-
989- # fig.add_subplot() always creates new axes, even if axes kwargs differ.
990- fig = plt .figure ()
991- ax = fig .add_subplot (1 , 1 , 1 )
992- ax1 = fig .add_subplot (1 , 1 , 1 )
993- assert ax is not None
994- assert ax1 is not ax
995- plt .close ()
996-
997- fig = plt .figure ()
998- ax = fig .add_subplot (1 , 1 , 1 , projection = 'polar' )
999- ax1 = fig .add_subplot (1 , 1 , 1 , projection = 'polar' )
1000- assert ax is not None
1001- assert ax1 is not ax
1002- plt .close ()
1003-
1004- fig = plt .figure ()
1005- ax = fig .add_subplot (1 , 1 , 1 , projection = 'polar' )
1006- ax1 = fig .add_subplot (1 , 1 , 1 )
1007- assert ax is not None
1008- assert ax1 .name == 'rectilinear'
1009- assert ax1 is not ax
1010- plt .close ()
1011-
1012- # plt.subplot() searches for axes with the same subplot spec, and if one
1013- # exists, and the kwargs match returns it, create a new one if they do not
1014- fig = plt .figure ()
1015- ax = plt .subplot (1 , 2 , 1 )
1016- ax1 = plt .subplot (1 , 2 , 1 )
1017- ax2 = plt .subplot (1 , 2 , 2 )
1018- # This will delete ax / ax1 as they fully overlap
1019- ax3 = plt .subplot (1 , 2 , 1 , projection = 'polar' )
1020- ax4 = plt .subplot (1 , 2 , 1 , projection = 'polar' )
1021- assert ax is not None
1022- assert ax1 is ax
1023- assert ax2 is not ax
1024- assert ax3 is not ax
1025- assert ax3 is ax4
1026-
1027- assert ax not in fig .axes
1028- assert ax2 in fig .axes
1029- assert ax3 in fig .axes
1030-
1031- assert ax .name == 'rectilinear'
1032- assert ax2 .name == 'rectilinear'
1033- assert ax3 .name == 'polar'
1034- plt .close ()
1035-
1036- # plt.gca() returns an existing axes, unless there were no axes.
1037- plt .figure ()
1038- ax = plt .gca ()
1039- ax1 = plt .gca ()
1040- assert ax is not None
1041- assert ax1 is ax
1042- plt .close ()
1043-
1044- # plt.gca() raises a DeprecationWarning if called with kwargs.
1045- plt .figure ()
1046- with pytest .warns (
1047- MatplotlibDeprecationWarning ,
1048- match = r'Calling gca\(\) with keyword arguments was deprecated' ):
1049- ax = plt .gca (projection = 'polar' )
1050- ax1 = plt .gca ()
1051- assert ax is not None
1052- assert ax1 is ax
1053- assert ax1 .name == 'polar'
1054- plt .close ()
1055-
1056- # plt.gca() ignores keyword arguments if an axes already exists.
1057- plt .figure ()
1058- ax = plt .gca ()
1059- with pytest .warns (
1060- MatplotlibDeprecationWarning ,
1061- match = r'Calling gca\(\) with keyword arguments was deprecated' ):
1062- ax1 = plt .gca (projection = 'polar' )
1063- assert ax is not None
1064- assert ax1 is ax
1065- assert ax1 .name == 'rectilinear'
1066- plt .close ()
1067-
1068- ax1 = plt .subplot (111 , projection = 'polar' )
1069- ax2 = plt .subplot (111 , polar = True )
1070- assert ax1 is ax2
0 commit comments