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

Method _locate

lib/mpl_toolkits/axes_grid1/axes_divider.py:202–247  ·  view source on GitHub ↗

Implementation of ``divider.new_locator().__call__``. The axes locator callable returned by ``new_locator()`` is created as a `functools.partial` of this method with *nx*, *ny*, *nx1*, and *ny1* specifying the requested cell.

(self, nx, ny, nx1, ny1, axes, renderer)

Source from the content-addressed store, hash-verified

200 return locator
201
202 def _locate(self, nx, ny, nx1, ny1, axes, renderer):
203 """
204 Implementation of ``divider.new_locator().__call__``.
205
206 The axes locator callable returned by ``new_locator()`` is created as
207 a `functools.partial` of this method with *nx*, *ny*, *nx1*, and *ny1*
208 specifying the requested cell.
209 """
210 nx += self._xrefindex
211 nx1 += self._xrefindex
212 ny += self._yrefindex
213 ny1 += self._yrefindex
214
215 fig_w, fig_h = self._fig.bbox.size / self._fig.dpi
216 x, y, w, h = self.get_position_runtime(axes, renderer)
217
218 hsizes = self.get_horizontal_sizes(renderer)
219 vsizes = self.get_vertical_sizes(renderer)
220 k_h = self._calc_k(hsizes, fig_w * w)
221 k_v = self._calc_k(vsizes, fig_h * h)
222
223 if self.get_aspect():
224 k = min(k_h, k_v)
225 ox = self._calc_offsets(hsizes, k)
226 oy = self._calc_offsets(vsizes, k)
227
228 ww = (ox[-1] - ox[0]) / fig_w
229 hh = (oy[-1] - oy[0]) / fig_h
230 pb = mtransforms.Bbox.from_bounds(x, y, w, h)
231 pb1 = mtransforms.Bbox.from_bounds(x, y, ww, hh)
232 x0, y0 = pb1.anchored(self.get_anchor(), pb).p0
233
234 else:
235 ox = self._calc_offsets(hsizes, k_h)
236 oy = self._calc_offsets(vsizes, k_v)
237 x0, y0 = x, y
238
239 if nx1 is None:
240 nx1 = -1
241 if ny1 is None:
242 ny1 = -1
243
244 x1, w1 = x0 + ox[nx] / fig_w, (ox[nx1] - ox[nx]) / fig_w
245 y1, h1 = y0 + oy[ny] / fig_h, (oy[ny1] - oy[ny]) / fig_h
246
247 return mtransforms.Bbox.from_bounds(x1, y1, w1, h1)
248
249 def append_size(self, position, size):
250 _api.check_in_list(["left", "right", "bottom", "top"],

Callers

nothing calls this directly

Calls 9

get_position_runtimeMethod · 0.95
get_horizontal_sizesMethod · 0.95
get_vertical_sizesMethod · 0.95
_calc_kMethod · 0.95
get_aspectMethod · 0.95
_calc_offsetsMethod · 0.95
get_anchorMethod · 0.95
from_boundsMethod · 0.80
anchoredMethod · 0.80

Tested by

no test coverage detected