MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _update_connectors

Method _update_connectors

lib/matplotlib/inset.py:171–221  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

169 return (xlim[0], ylim[0], xlim[1] - xlim[0], ylim[1] - ylim[0])
170
171 def _update_connectors(self):
172 (x, y) = self._rectangle.get_xy()
173 width = self._rectangle.get_width()
174 height = self._rectangle.get_height()
175
176 existing_connectors = self._connectors or [None] * 4
177
178 # connect the inset_axes to the rectangle
179 for xy_inset_ax, existing in zip([(0, 0), (0, 1), (1, 0), (1, 1)],
180 existing_connectors):
181 # inset_ax positions are in axes coordinates
182 # The 0, 1 values define the four edges if the inset_ax
183 # lower_left, upper_left, lower_right upper_right.
184 ex, ey = xy_inset_ax
185 if self.axes.xaxis.get_inverted():
186 ex = 1 - ex
187 if self.axes.yaxis.get_inverted():
188 ey = 1 - ey
189 xy_data = x + ex * width, y + ey * height
190 if existing is None:
191 # Create new connection patch with styles inherited from the
192 # parent artist.
193 p = ConnectionPatch(
194 xyA=xy_inset_ax, coordsA=self._inset_ax.transAxes,
195 xyB=xy_data, coordsB=self.rectangle.get_data_transform(),
196 arrowstyle="-",
197 edgecolor=self._edgecolor, alpha=self.get_alpha(),
198 linestyle=self._linestyle, linewidth=self._linewidth)
199 self._connectors.append(p)
200 else:
201 # Only update positioning of existing connection patch. We
202 # do not want to override any style settings made by the user.
203 existing.xy1 = xy_inset_ax
204 existing.xy2 = xy_data
205 existing.coords1 = self._inset_ax.transAxes
206 existing.coords2 = self.rectangle.get_data_transform()
207
208 if existing is None:
209 # decide which two of the lines to keep visible....
210 pos = self._inset_ax.get_position()
211 bboxins = pos.transformed(self.get_figure(root=False).transSubfigure)
212 rectbbox = transforms.Bbox.from_bounds(x, y, width, height).transformed(
213 self._rectangle.get_transform())
214 x0 = rectbbox.x0 < bboxins.x0
215 x1 = rectbbox.x1 < bboxins.x1
216 y0 = rectbbox.y0 < bboxins.y0
217 y1 = rectbbox.y1 < bboxins.y1
218 self._connectors[0].set_visible(x0 ^ y0)
219 self._connectors[1].set_visible(x0 == y1)
220 self._connectors[2].set_visible(x1 == y0)
221 self._connectors[3].set_visible(x1 ^ y1)
222
223 @property
224 def rectangle(self):

Callers 1

connectorsMethod · 0.95

Calls 13

ConnectionPatchClass · 0.90
get_invertedMethod · 0.80
get_data_transformMethod · 0.80
from_boundsMethod · 0.80
get_xyMethod · 0.45
get_widthMethod · 0.45
get_heightMethod · 0.45
get_alphaMethod · 0.45
get_positionMethod · 0.45
transformedMethod · 0.45
get_figureMethod · 0.45
get_transformMethod · 0.45

Tested by

no test coverage detected