def _update_locators(self): h = [] h_ax_pos = [] h_cb_pos = [] for ax in self._column_refax: if h: h.append(self._horiz_pad_size) # Size.Fixed(self._axes_pad)) h_ax_pos.append(len(h)) if ax: sz = Size.AxesX(ax) else: sz = Size.AxesX(self.axes_llc) h.append(sz) if self._colorbar_mode == "each" and self._colorbar_location == "right": h.append(Size.from_any(self._colorbar_pad, sz)) h_cb_pos.append(len(h)) h.append(Size.from_any(self._colorbar_size, sz)) v = [] v_ax_pos = [] v_cb_pos = [] for ax in self._row_refax[::-1]: if v: v.append(self._horiz_pad_size) # Size.Fixed(self._axes_pad)) v_ax_pos.append(len(v)) if ax: sz = Size.AxesY(ax) else: sz = Size.AxesY(self.axes_llc) v.append(sz) if self._colorbar_mode == "each" and self._colorbar_location == "top": v.append(Size.from_any(self._colorbar_pad, sz)) v_cb_pos.append(len(v)) v.append(Size.from_any(self._colorbar_size, sz)) for i in range(self.ngrids): col, row = self._get_col_row(i) # locator = self._divider.new_locator(nx=4*col, ny=2*(self._nrows - row - 1)) locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_ax_pos[self._nrows - 1 - row]) self.axes_all[i].set_axes_locator(locator) if self._colorbar_mode == "each": if self._colorbar_location == "right": locator = self._divider.new_locator(nx=h_cb_pos[col], ny=v_ax_pos[self._nrows - 1 - row]) elif self._colorbar_location == "top": locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_cb_pos[self._nrows - 1 - row]) self.cbar_axes[i].set_axes_locator(locator) if self._colorbar_mode == "single": if self._colorbar_location == "right": # sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows) sz = Size.Fraction(self._nrows, Size.AxesX(self.axes_llc)) h.append(Size.from_any(self._colorbar_pad, sz)) h.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=-2, ny=0, ny1=-1) elif self._colorbar_location == "top": # sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols) sz = Size.Fraction(self._ncols, Size.AxesY(self.axes_llc)) v.append(Size.from_any(self._colorbar_pad, sz)) v.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=0, nx1=-1, ny=-2) for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[0].set_axes_locator(locator) self.cbar_axes[0].set_visible(True) elif self._colorbar_mode == "each": for i in range(self.ngrids): self.cbar_axes[i].set_visible(True) else: for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[i].set_position([1.0, 1.0, 0.001, 0.001], which="active") self._divider.set_horizontal(h) self._divider.set_vertical(v)
def _update_locators(self): h = [] v = [] h_ax_pos = [] h_cb_pos = [] if self._colorbar_mode == "single" and self._colorbar_location in ('left', 'bottom'): if self._colorbar_location == "left": #sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows) sz = Size.Fraction(self._nrows, Size.AxesX(self.axes_llc)) h.append(Size.from_any(self._colorbar_size, sz)) h.append(Size.from_any(self._colorbar_pad, sz)) locator = self._divider.new_locator(nx=0, ny=0, ny1=-1) elif self._colorbar_location == "bottom": #sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols) sz = Size.Fraction(self._ncols, Size.AxesY(self.axes_llc)) v.append(Size.from_any(self._colorbar_size, sz)) v.append(Size.from_any(self._colorbar_pad, sz)) locator = self._divider.new_locator(nx=0, nx1=-1, ny=0) for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[0].set_axes_locator(locator) self.cbar_axes[0].set_visible(True) for col,ax in enumerate(self._column_refax): if h: h.append(self._horiz_pad_size) #Size.Fixed(self._axes_pad)) if ax: sz = Size.AxesX(ax) else: sz = Size.AxesX(self.axes_llc) if (self._colorbar_mode == "each" or (self._colorbar_mode == 'edge' and col == 0)) and self._colorbar_location == "left": h_cb_pos.append(len(h)) h.append(Size.from_any(self._colorbar_size, sz)) h.append(Size.from_any(self._colorbar_pad, sz)) h_ax_pos.append(len(h)) h.append(sz) if (self._colorbar_mode == "each" or (self._colorbar_mode == 'edge' and col == self._ncols - 1)) and self._colorbar_location == "right": h.append(Size.from_any(self._colorbar_pad, sz)) h_cb_pos.append(len(h)) h.append(Size.from_any(self._colorbar_size, sz)) v_ax_pos = [] v_cb_pos = [] for row,ax in enumerate(self._row_refax[::-1]): if v: v.append(self._horiz_pad_size) #Size.Fixed(self._axes_pad)) if ax: sz = Size.AxesY(ax) else: sz = Size.AxesY(self.axes_llc) if (self._colorbar_mode == "each" or (self._colorbar_mode == 'edge' and row == 0)) and self._colorbar_location == "bottom": v_cb_pos.append(len(v)) v.append(Size.from_any(self._colorbar_size, sz)) v.append(Size.from_any(self._colorbar_pad, sz)) v_ax_pos.append(len(v)) v.append(sz) if (self._colorbar_mode == "each" or (self._colorbar_mode == 'edge' and row == self._nrows - 1)) and self._colorbar_location == "top": v.append(Size.from_any(self._colorbar_pad, sz)) v_cb_pos.append(len(v)) v.append(Size.from_any(self._colorbar_size, sz)) for i in range(self.ngrids): col, row = self._get_col_row(i) #locator = self._divider.new_locator(nx=4*col, ny=2*(self._nrows - row - 1)) locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_ax_pos[self._nrows -1 - row]) self.axes_all[i].set_axes_locator(locator) if self._colorbar_mode == "each": if self._colorbar_location in ("right", "left"): locator = self._divider.new_locator(nx=h_cb_pos[col], ny=v_ax_pos[self._nrows -1 - row]) elif self._colorbar_location in ("top", "bottom"): locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_cb_pos[self._nrows -1 - row]) self.cbar_axes[i].set_axes_locator(locator) elif self._colorbar_mode == 'edge': if ((self._colorbar_location == 'left' and col == 0) or (self._colorbar_location == 'right' and col == self._ncols-1)): locator = self._divider.new_locator(nx=h_cb_pos[0], ny=v_ax_pos[self._nrows -1 - row]) self.cbar_axes[row].set_axes_locator(locator) elif ((self._colorbar_location == 'bottom' and row == self._nrows - 1) or (self._colorbar_location == 'top' and row == 0)): locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_cb_pos[0]) self.cbar_axes[col].set_axes_locator(locator) if self._colorbar_mode == "single": if self._colorbar_location == "right": #sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows) sz = Size.Fraction(self._nrows, Size.AxesX(self.axes_llc)) h.append(Size.from_any(self._colorbar_pad, sz)) h.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=-2, ny=0, ny1=-1) elif self._colorbar_location == "top": #sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols) sz = Size.Fraction(self._ncols, Size.AxesY(self.axes_llc)) v.append(Size.from_any(self._colorbar_pad, sz)) v.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=0, nx1=-1, ny=-2) if self._colorbar_location in ("right", "top"): for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[0].set_axes_locator(locator) self.cbar_axes[0].set_visible(True) elif self._colorbar_mode == "each": for i in range(self.ngrids): self.cbar_axes[i].set_visible(True) elif self._colorbar_mode == "edge": if self._colorbar_location in ('right', 'left'): count = self._nrows else: count = self._ncols for i in range(count): self.cbar_axes[i].set_visible(True) for j in range(i + 1, self.ngrids): self.cbar_axes[j].set_visible(False) else: for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[i].set_position([1., 1., 0.001, 0.001], which="active") self._divider.set_horizontal(h) self._divider.set_vertical(v)
def _update_locators(self): h = [] v = [] h_ax_pos = [] h_cb_pos = [] if self._colorbar_mode == "single" and self._colorbar_location in ("left", "bottom"): if self._colorbar_location == "left": # sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows) sz = Size.Fraction(self._nrows, Size.AxesX(self.axes_llc)) h.append(Size.from_any(self._colorbar_size, sz)) h.append(Size.from_any(self._colorbar_pad, sz)) locator = self._divider.new_locator(nx=0, ny=0, ny1=-1) elif self._colorbar_location == "bottom": # sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols) sz = Size.Fraction(self._ncols, Size.AxesY(self.axes_llc)) v.append(Size.from_any(self._colorbar_size, sz)) v.append(Size.from_any(self._colorbar_pad, sz)) locator = self._divider.new_locator(nx=0, nx1=-1, ny=0) for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[0].set_axes_locator(locator) self.cbar_axes[0].set_visible(True) for col, ax in enumerate(self._column_refax): if h: h.append(self._horiz_pad_size) # Size.Fixed(self._axes_pad)) if ax: sz = Size.AxesX(ax) else: sz = Size.AxesX(self.axes_llc) if ( self._colorbar_mode == "each" or (self._colorbar_mode == "edge" and col == 0) ) and self._colorbar_location == "left": h_cb_pos.append(len(h)) h.append(Size.from_any(self._colorbar_size, sz)) h.append(Size.from_any(self._colorbar_pad, sz)) h_ax_pos.append(len(h)) h.append(sz) if ( self._colorbar_mode == "each" or (self._colorbar_mode == "edge" and col == self._ncols - 1) ) and self._colorbar_location == "right": h.append(Size.from_any(self._colorbar_pad, sz)) h_cb_pos.append(len(h)) h.append(Size.from_any(self._colorbar_size, sz)) v_ax_pos = [] v_cb_pos = [] for row, ax in enumerate(self._row_refax[::-1]): if v: v.append(self._horiz_pad_size) # Size.Fixed(self._axes_pad)) if ax: sz = Size.AxesY(ax) else: sz = Size.AxesY(self.axes_llc) if ( self._colorbar_mode == "each" or (self._colorbar_mode == "edge" and row == 0) ) and self._colorbar_location == "bottom": v_cb_pos.append(len(v)) v.append(Size.from_any(self._colorbar_size, sz)) v.append(Size.from_any(self._colorbar_pad, sz)) v_ax_pos.append(len(v)) v.append(sz) if ( self._colorbar_mode == "each" or (self._colorbar_mode == "edge" and row == self._nrows - 1) ) and self._colorbar_location == "top": v.append(Size.from_any(self._colorbar_pad, sz)) v_cb_pos.append(len(v)) v.append(Size.from_any(self._colorbar_size, sz)) for i in range(self.ngrids): col, row = self._get_col_row(i) # locator = self._divider.new_locator(nx=4*col, ny=2*(self._nrows - row - 1)) locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_ax_pos[self._nrows - 1 - row]) self.axes_all[i].set_axes_locator(locator) if self._colorbar_mode == "each": if self._colorbar_location in ("right", "left"): locator = self._divider.new_locator(nx=h_cb_pos[col], ny=v_ax_pos[self._nrows - 1 - row]) elif self._colorbar_location in ("top", "bottom"): locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_cb_pos[self._nrows - 1 - row]) self.cbar_axes[i].set_axes_locator(locator) elif self._colorbar_mode == "edge": if (self._colorbar_location == "left" and col == 0) or ( self._colorbar_location == "right" and col == self._ncols - 1 ): locator = self._divider.new_locator(nx=h_cb_pos[0], ny=v_ax_pos[self._nrows - 1 - row]) self.cbar_axes[row].set_axes_locator(locator) elif (self._colorbar_location == "bottom" and row == self._nrows - 1) or ( self._colorbar_location == "top" and row == 0 ): locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_cb_pos[0]) self.cbar_axes[col].set_axes_locator(locator) if self._colorbar_mode == "single": if self._colorbar_location == "right": # sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows) sz = Size.Fraction(self._nrows, Size.AxesX(self.axes_llc)) h.append(Size.from_any(self._colorbar_pad, sz)) h.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=-2, ny=0, ny1=-1) elif self._colorbar_location == "top": # sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols) sz = Size.Fraction(self._ncols, Size.AxesY(self.axes_llc)) v.append(Size.from_any(self._colorbar_pad, sz)) v.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=0, nx1=-1, ny=-2) if self._colorbar_location in ("right", "top"): for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[0].set_axes_locator(locator) self.cbar_axes[0].set_visible(True) elif self._colorbar_mode == "each": for i in range(self.ngrids): self.cbar_axes[i].set_visible(True) elif self._colorbar_mode == "edge": if self._colorbar_location in ("right", "left"): count = self._nrows else: count = self._ncols for i in range(count): self.cbar_axes[i].set_visible(True) for j in range(i + 1, self.ngrids): self.cbar_axes[j].set_visible(False) else: for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[i].set_position([1.0, 1.0, 0.001, 0.001], which="active") self._divider.set_horizontal(h) self._divider.set_vertical(v)
def _update_locators(self): h = [] h_ax_pos = [] h_cb_pos = [] for ax in self._column_refax: if h: h.append(self._horiz_pad_size) #Size.Fixed(self._axes_pad)) h_ax_pos.append(len(h)) if ax: sz = Size.AxesX(ax) else: sz = Size.AxesX(self.axes_llc) h.append(sz) if self._colorbar_mode == "each" and self._colorbar_location == "right": h.append(Size.from_any(self._colorbar_pad, sz)) h_cb_pos.append(len(h)) h.append(Size.from_any(self._colorbar_size, sz)) v = [] v_ax_pos = [] v_cb_pos = [] for ax in self._row_refax[::-1]: if v: v.append(self._horiz_pad_size) #Size.Fixed(self._axes_pad)) v_ax_pos.append(len(v)) if ax: sz = Size.AxesY(ax) else: sz = Size.AxesY(self.axes_llc) v.append(sz) if self._colorbar_mode == "each" and self._colorbar_location == "top": v.append(Size.from_any(self._colorbar_pad, sz)) v_cb_pos.append(len(v)) v.append(Size.from_any(self._colorbar_size, sz)) for i in range(self.ngrids): col, row = self._get_col_row(i) #locator = self._divider.new_locator(nx=4*col, ny=2*(self._nrows - row - 1)) locator = self._divider.new_locator(nx=h_ax_pos[col], ny=v_ax_pos[self._nrows - 1 - row]) self.axes_all[i].set_axes_locator(locator) if self._colorbar_mode == "each": if self._colorbar_location == "right": locator = self._divider.new_locator( nx=h_cb_pos[col], ny=v_ax_pos[self._nrows - 1 - row]) elif self._colorbar_location == "top": locator = self._divider.new_locator( nx=h_ax_pos[col], ny=v_cb_pos[self._nrows - 1 - row]) self.cbar_axes[i].set_axes_locator(locator) if self._colorbar_mode == "single": if self._colorbar_location == "right": #sz = Size.Fraction(Size.AxesX(self.axes_llc), self._nrows) sz = Size.Fraction(self._nrows, Size.AxesX(self.axes_llc)) h.append(Size.from_any(self._colorbar_pad, sz)) h.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=-2, ny=0, ny1=-1) elif self._colorbar_location == "top": #sz = Size.Fraction(Size.AxesY(self.axes_llc), self._ncols) sz = Size.Fraction(self._ncols, Size.AxesY(self.axes_llc)) v.append(Size.from_any(self._colorbar_pad, sz)) v.append(Size.from_any(self._colorbar_size, sz)) locator = self._divider.new_locator(nx=0, nx1=-1, ny=-2) for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[0].set_axes_locator(locator) self.cbar_axes[0].set_visible(True) elif self._colorbar_mode == "each": for i in range(self.ngrids): self.cbar_axes[i].set_visible(True) else: for i in range(self.ngrids): self.cbar_axes[i].set_visible(False) self.cbar_axes[i].set_position([1., 1., 0.001, 0.001], which="active") self._divider.set_horizontal(h) self._divider.set_vertical(v)