@@ -251,28 +251,24 @@ def set_label_mode(self, mode):
251251 - "keep": Do not do anything.
252252 """
253253 _api .check_in_list (["all" , "L" , "1" , "keep" ], mode = mode )
254- is_last_row , is_first_col = (
255- np .mgrid [:self ._nrows , :self ._ncols ] == [[[self ._nrows - 1 ]], [[0 ]]])
256- if mode == "all" :
257- bottom = left = np .full ((self ._nrows , self ._ncols ), True )
258- elif mode == "L" :
259- bottom = is_last_row
260- left = is_first_col
261- elif mode == "1" :
262- bottom = left = is_last_row & is_first_col
263- else :
254+ if mode == "keep" :
264255 return
265- for i in range (self ._nrows ):
266- for j in range (self ._ncols ):
267- ax = self .axes_row [i ][j ]
268- if isinstance (ax .axis , MethodType ):
269- bottom_axis = SimpleAxisArtist (ax .xaxis , 1 , ax .spines ["bottom" ])
270- left_axis = SimpleAxisArtist (ax .yaxis , 1 , ax .spines ["left" ])
271- else :
272- bottom_axis = ax .axis ["bottom" ]
273- left_axis = ax .axis ["left" ]
274- bottom_axis .toggle (ticklabels = bottom [i , j ], label = bottom [i , j ])
275- left_axis .toggle (ticklabels = left [i , j ], label = left [i , j ])
256+ for i , j in np .ndindex (self ._nrows , self ._ncols ):
257+ ax = self .axes_row [i ][j ]
258+ if isinstance (ax .axis , MethodType ):
259+ bottom_axis = SimpleAxisArtist (ax .xaxis , 1 , ax .spines ["bottom" ])
260+ left_axis = SimpleAxisArtist (ax .yaxis , 1 , ax .spines ["left" ])
261+ else :
262+ bottom_axis = ax .axis ["bottom" ]
263+ left_axis = ax .axis ["left" ]
264+ display_at_bottom = (i == self ._nrows - 1 if mode == "L" else
265+ i == self ._nrows - 1 and j == 0 if mode == "1" else
266+ True ) # if mode == "all"
267+ display_at_left = (j == 0 if mode == "L" else
268+ i == self ._nrows - 1 and j == 0 if mode == "1" else
269+ True ) # if mode == "all"
270+ bottom_axis .toggle (ticklabels = display_at_bottom , label = display_at_bottom )
271+ left_axis .toggle (ticklabels = display_at_left , label = display_at_left )
276272
277273 def get_divider (self ):
278274 return self ._divider
0 commit comments