MCPcopy
hub / github.com/matplotlib/matplotlib / _init_locators

Method _init_locators

lib/mpl_toolkits/axes_grid1/axes_grid.py:403–561  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

401 ax.cax = cax
402
403 def _init_locators(self):
404 # Slightly abusing this method to inject colorbar creation into init.
405
406 if self._colorbar_pad is None:
407 # horizontal or vertical arrangement?
408 if self._colorbar_location in ("left", "right"):
409 self._colorbar_pad = self._horiz_pad_size.fixed_size
410 else:
411 self._colorbar_pad = self._vert_pad_size.fixed_size
412 self.cbar_axes = [
413 _cbaraxes_class_factory(self._defaultAxesClass)(
414 self.axes_all[0].get_figure(root=False), self._divider.get_position(),
415 orientation=self._colorbar_location)
416 for _ in range(self.n_axes)]
417
418 cb_mode = self._colorbar_mode
419 cb_location = self._colorbar_location
420
421 h = []
422 v = []
423
424 h_ax_pos = []
425 h_cb_pos = []
426 if cb_mode == "single" and cb_location in ("left", "bottom"):
427 if cb_location == "left":
428 sz = self._nrows * Size.AxesX(self.axes_llc)
429 h.append(Size.from_any(self._colorbar_size, sz))
430 h.append(Size.from_any(self._colorbar_pad, sz))
431 locator = self._divider.new_locator(nx=0, ny=0, ny1=-1)
432 elif cb_location == "bottom":
433 sz = self._ncols * Size.AxesY(self.axes_llc)
434 v.append(Size.from_any(self._colorbar_size, sz))
435 v.append(Size.from_any(self._colorbar_pad, sz))
436 locator = self._divider.new_locator(nx=0, nx1=-1, ny=0)
437 for i in range(self.n_axes):
438 self.cbar_axes[i].set_visible(False)
439 self.cbar_axes[0].set_axes_locator(locator)
440 self.cbar_axes[0].set_visible(True)
441
442 for col, ax in enumerate(self.axes_row[0]):
443 if col != 0:
444 h.append(self._horiz_pad_size)
445
446 if ax:
447 sz = Size.AxesX(ax, aspect="axes", ref_ax=self.axes_all[0])
448 else:
449 sz = Size.AxesX(self.axes_all[0],
450 aspect="axes", ref_ax=self.axes_all[0])
451
452 if (cb_location == "left"
453 and (cb_mode == "each"
454 or (cb_mode == "edge" and col == 0))):
455 h_cb_pos.append(len(h))
456 h.append(Size.from_any(self._colorbar_size, sz))
457 h.append(Size.from_any(self._colorbar_pad, sz))
458
459 h_ax_pos.append(len(h))
460 h.append(sz)

Callers

nothing calls this directly

Calls 9

_get_col_rowMethod · 0.80
set_horizontalMethod · 0.80
set_verticalMethod · 0.80
get_figureMethod · 0.45
get_positionMethod · 0.45
new_locatorMethod · 0.45
set_visibleMethod · 0.45
set_axes_locatorMethod · 0.45
set_positionMethod · 0.45

Tested by

no test coverage detected