@@ -1299,13 +1299,15 @@ def axis(self, *v, **kwargs):
12991299 ymin , ymax = self .get_ylim ()
13001300 return xmin , xmax , ymin , ymax
13011301
1302+ emit = kwargs .get ('emit' , True )
1303+
13021304 if len (v ) == 1 and is_string_like (v [0 ]):
13031305 s = v [0 ].lower ()
13041306 if s == 'on' :
13051307 self .set_axis_on ()
13061308 elif s == 'off' :
13071309 self .set_axis_off ()
1308- elif s in ('equal' , 'tight' , 'scaled' , 'normal' , 'auto' , 'image' ):
1310+ elif s in ('equal' , 'tight' , 'scaled' , 'normal' , 'auto' , 'image' , 'square' ):
13091311 self .set_autoscale_on (True )
13101312 self .set_aspect ('auto' )
13111313 self .autoscale_view (tight = False )
@@ -1322,15 +1324,23 @@ def axis(self, *v, **kwargs):
13221324 self .autoscale_view (tight = True )
13231325 self .set_autoscale_on (False )
13241326 self .set_aspect ('equal' , adjustable = 'box' , anchor = 'C' )
1327+ elif s == 'square' :
1328+ self .set_aspect ('equal' , adjustable = 'box' , anchor = 'C' )
1329+ self .set_autoscale_on (False )
1330+ xlim = self .get_xlim ()
1331+ ylim = self .get_ylim ()
1332+ minlim = min (xlim [0 ], ylim [0 ])
1333+ maxlim = max (xlim [1 ], ylim [1 ])
1334+ self .set_xlim ([minlim , maxlim ], emit = emit , auto = False )
1335+ self .set_ylim ([minlim , maxlim ], emit = emit , auto = False )
13251336
13261337 else :
13271338 raise ValueError ('Unrecognized string %s to axis; '
13281339 'try on or off' % s )
13291340 xmin , xmax = self .get_xlim ()
13301341 ymin , ymax = self .get_ylim ()
13311342 return xmin , xmax , ymin , ymax
1332-
1333- emit = kwargs .get ('emit' , True )
1343+
13341344 try :
13351345 v [0 ]
13361346 except IndexError :
0 commit comments