@@ -176,24 +176,26 @@ def _clip_grid_lines_and_find_ticks(self, lines, values, levs, bb):
176
176
return gi
177
177
178
178
def update_transform (self , aux_trans ):
179
- if isinstance (aux_trans , Transform ):
180
- def transform_xy (x , y ):
181
- ll1 = np .column_stack ([x , y ])
182
- ll2 = aux_trans .transform (ll1 )
183
- lon , lat = ll2 [:, 0 ], ll2 [:, 1 ]
184
- return lon , lat
185
-
186
- def inv_transform_xy (x , y ):
187
- ll1 = np .column_stack ([x , y ])
188
- ll2 = aux_trans .inverted ().transform (ll1 )
189
- lon , lat = ll2 [:, 0 ], ll2 [:, 1 ]
190
- return lon , lat
191
-
179
+ if not isinstance (aux_trans , Transform ) and len (aux_trans ) != 2 :
180
+ raise TypeError ("'aux_trans' must be either a Transform instance "
181
+ "or a pair of callables" )
182
+ self ._aux_transform = aux_trans
183
+
184
+ def transform_xy (self , x , y ):
185
+ aux_trf = self ._aux_transform
186
+ if isinstance (aux_trf , Transform ):
187
+ return aux_trf .transform (np .column_stack ([x , y ])).T
192
188
else :
193
- transform_xy , inv_transform_xy = aux_trans
189
+ transform_xy , inv_transform_xy = aux_trf
190
+ return transform_xy (x , y )
194
191
195
- self .transform_xy = transform_xy
196
- self .inv_transform_xy = inv_transform_xy
192
+ def inv_transform_xy (self , x , y ):
193
+ aux_trf = self ._aux_transform
194
+ if isinstance (aux_trf , Transform ):
195
+ return aux_trf .inverted ().transform (np .column_stack ([x , y ])).T
196
+ else :
197
+ transform_xy , inv_transform_xy = aux_trf
198
+ return inv_transform_xy (x , y )
197
199
198
200
def update (self , ** kw ):
199
201
for k in kw :
0 commit comments