@@ -75,7 +75,7 @@ def _set_lim_and_transforms(self):
75
75
76
76
def set_viewlim_mode (self , mode ):
77
77
if mode not in [None , "equal" , "transform" ]:
78
- raise ValueError ("Unknown mode : %s" % (mode ,))
78
+ raise ValueError ("Unknown mode: %s" % (mode ,))
79
79
else :
80
80
self ._viewlim_mode = mode
81
81
@@ -90,17 +90,18 @@ def update_viewlim(self):
90
90
elif mode == "equal" :
91
91
self .axes .viewLim .set (viewlim )
92
92
elif mode == "transform" :
93
- self .axes .viewLim .set (viewlim .transformed (self .transAux .inverted ()))
93
+ self .axes .viewLim .set (
94
+ viewlim .transformed (self .transAux .inverted ()))
94
95
else :
95
- raise ValueError ("Unknown mode : %s" % (self ._viewlim_mode ,))
96
+ raise ValueError ("Unknown mode: %s" % (self ._viewlim_mode ,))
96
97
97
98
def _pcolor (self , super_pcolor , * XYC , ** kwargs ):
98
99
if len (XYC ) == 1 :
99
100
C = XYC [0 ]
100
101
ny , nx = C .shape
101
102
102
- gx = np .arange (- 0.5 , nx , 1. )
103
- gy = np .arange (- 0.5 , ny , 1. )
103
+ gx = np .arange (- 0.5 , nx )
104
+ gy = np .arange (- 0.5 , ny )
104
105
105
106
X , Y = np .meshgrid (gx , gy )
106
107
else :
@@ -110,10 +111,10 @@ def _pcolor(self, super_pcolor, *XYC, **kwargs):
110
111
mesh = super_pcolor (self , X , Y , C , ** kwargs )
111
112
else :
112
113
orig_shape = X .shape
113
- xy = np .vstack ([X .flat , Y .flat ])
114
- xyt = xy .transpose ()
114
+ xyt = np .column_stack ([X .flat , Y .flat ])
115
115
wxy = self .transAux .transform (xyt )
116
- gx , gy = wxy [:,0 ].reshape (orig_shape ), wxy [:,1 ].reshape (orig_shape )
116
+ gx = wxy [:, 0 ].reshape (orig_shape )
117
+ gy = wxy [:, 1 ].reshape (orig_shape )
117
118
mesh = super_pcolor (self , gx , gy , C , ** kwargs )
118
119
mesh .set_transform (self ._parent_axes .transData )
119
120
@@ -131,10 +132,10 @@ def _contour(self, super_contour, *XYCL, **kwargs):
131
132
C = XYCL [0 ]
132
133
ny , nx = C .shape
133
134
134
- gx = np .arange (0. , nx , 1. )
135
- gy = np .arange (0. , ny , 1. )
135
+ gx = np .arange (0. , nx )
136
+ gy = np .arange (0. , ny )
136
137
137
- X ,Y = np .meshgrid (gx , gy )
138
+ X , Y = np .meshgrid (gx , gy )
138
139
CL = XYCL
139
140
else :
140
141
X , Y = XYCL [:2 ]
@@ -144,10 +145,10 @@ def _contour(self, super_contour, *XYCL, **kwargs):
144
145
cont = super_contour (self , X , Y , * CL , ** kwargs )
145
146
else :
146
147
orig_shape = X .shape
147
- xy = np .vstack ([X .flat , Y .flat ])
148
- xyt = xy .transpose ()
148
+ xyt = np .column_stack ([X .flat , Y .flat ])
149
149
wxy = self .transAux .transform (xyt )
150
- gx , gy = wxy [:,0 ].reshape (orig_shape ), wxy [:,1 ].reshape (orig_shape )
150
+ gx = wxy [:, 0 ].reshape (orig_shape )
151
+ gy = wxy [:, 1 ].reshape (orig_shape )
151
152
cont = super_contour (self , gx , gy , * CL , ** kwargs )
152
153
for c in cont .collections :
153
154
c .set_transform (self ._parent_axes .transData )
@@ -183,19 +184,6 @@ def parasite_axes_auxtrans_class_factory(axes_class=None):
183
184
axes_class = ParasiteAxes )
184
185
185
186
186
- def _get_handles (ax ):
187
- handles = ax .lines [:]
188
- handles .extend (ax .patches )
189
- handles .extend ([c for c in ax .collections
190
- if isinstance (c , mcoll .LineCollection )])
191
- handles .extend ([c for c in ax .collections
192
- if isinstance (c , mcoll .RegularPolyCollection )])
193
- handles .extend ([c for c in ax .collections
194
- if isinstance (c , mcoll .CircleCollection )])
195
-
196
- return handles
197
-
198
-
199
187
class HostAxesBase :
200
188
def __init__ (self , * args , ** kwargs ):
201
189
self .parasites = []
@@ -347,7 +335,7 @@ def get_tightbbox(self, renderer, call_axes_locator=True):
347
335
bbs = [ax .get_tightbbox (renderer , call_axes_locator )
348
336
for ax in self .parasites ]
349
337
bbs .append (super ().get_tightbbox (renderer , call_axes_locator ))
350
- return Bbox .union ([b for b in bbs if b .width != 0 or b .height != 0 ])
338
+ return Bbox .union ([b for b in bbs if b .width != 0 or b .height != 0 ])
351
339
352
340
353
341
@functools .lru_cache (None )
@@ -395,6 +383,7 @@ def host_axes(*args, axes_class=None, figure=None, **kwargs):
395
383
plt .draw_if_interactive ()
396
384
return ax
397
385
386
+
398
387
def host_subplot (* args , axes_class = None , figure = None , ** kwargs ):
399
388
"""
400
389
Create a subplot that can act as a host to parasitic axes.
0 commit comments