@@ -154,50 +154,43 @@ def scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False,
154
154
ax .set_xlabel ('' )
155
155
ax .set_ylabel ('' )
156
156
157
- ax .xaxis .set_visible (False )
158
- ax .yaxis .set_visible (False )
159
-
160
- # setup labels
161
- if i == 0 and j % 2 == 1 :
162
- ax .set_xlabel (b , visible = True )
163
- ax .xaxis .set_visible (True )
164
- ax .set_xlabel (b )
165
- ax .xaxis .set_ticks_position ('top' )
166
- ax .xaxis .set_label_position ('top' )
167
- setp (ax .get_xticklabels (), rotation = 90 )
168
- elif i == n - 1 and j % 2 == 0 :
169
- ax .set_xlabel (b , visible = True )
170
- ax .xaxis .set_visible (True )
171
- ax .set_xlabel (b )
172
- ax .xaxis .set_ticks_position ('bottom' )
173
- ax .xaxis .set_label_position ('bottom' )
174
- setp (ax .get_xticklabels (), rotation = 90 )
175
- elif j == 0 and i % 2 == 0 :
176
- ax .set_ylabel (a , visible = True )
177
- ax .yaxis .set_visible (True )
178
- ax .set_ylabel (a )
179
- ax .yaxis .set_ticks_position ('left' )
180
- ax .yaxis .set_label_position ('left' )
181
- elif j == n - 1 and i % 2 == 1 :
182
- ax .set_ylabel (a , visible = True )
183
- ax .yaxis .set_visible (True )
184
- ax .set_ylabel (a )
185
- ax .yaxis .set_ticks_position ('right' )
186
- ax .yaxis .set_label_position ('right' )
187
-
188
- # ax.grid(b=grid)
189
-
190
- axes [0 , 0 ].yaxis .set_visible (False )
191
- axes [n - 1 , n - 1 ].xaxis .set_visible (False )
192
- axes [n - 1 , n - 1 ].yaxis .set_visible (False )
193
- axes [0 , n - 1 ].yaxis .tick_right ()
157
+ _label_axis (ax , kind = 'x' , label = b , position = 'bottom' , rotate = True )
158
+
159
+ _label_axis (ax , kind = 'y' , label = a , position = 'left' )
160
+
161
+ if j != 0 :
162
+ ax .yaxis .set_visible (False )
163
+ if i != n - 1 :
164
+ ax .xaxis .set_visible (False )
194
165
195
166
for ax in axes .flat :
196
167
setp (ax .get_xticklabels (), fontsize = 8 )
197
168
setp (ax .get_yticklabels (), fontsize = 8 )
198
169
199
170
return axes
200
171
172
+ def _label_axis (ax , kind = 'x' , label = '' , position = 'top' ,
173
+ ticks = True , rotate = False ):
174
+
175
+ from matplotlib .artist import setp
176
+ if kind == 'x' :
177
+ ax .set_xlabel (label , visible = True )
178
+ ax .xaxis .set_visible (True )
179
+ ax .xaxis .set_ticks_position (position )
180
+ ax .xaxis .set_label_position (position )
181
+ if rotate :
182
+ setp (ax .get_xticklabels (), rotation = 90 )
183
+ elif kind == 'y' :
184
+ ax .yaxis .set_visible (True )
185
+ ax .set_ylabel (label , visible = True )
186
+ # ax.set_ylabel(a)
187
+ ax .yaxis .set_ticks_position (position )
188
+ ax .yaxis .set_label_position (position )
189
+ return
190
+
191
+
192
+
193
+
201
194
202
195
def _gca ():
203
196
import matplotlib .pyplot as plt
0 commit comments