Ejemplo n.º 1
0
 def add_colorbar(self,
                  contour,
                  label=None,
                  tick_levels=None,
                  width="3%",
                  height="30%",
                  cb_format=None,
                  fraction=0.05,
                  pad=0.08,
                  shrink=0.7,
                  loc=4,
                  extend="both",
                  tick_position="left"):
     if not self.noframe:
         cbar = self.fig.colorbar(contour,
                                  fraction=fraction,
                                  pad=pad,
                                  shrink=shrink)
         cbar.set_label(label)
     else:
         axins1 = mpl_toolkits.axes_grid1.inset_locator.inset_axes(
             self.bm.ax, width=width, height=height, loc=loc)
         self.fig.colorbar(contour,
                           cax=axins1,
                           orientation="vertical",
                           ticks=tick_levels,
                           extend=extend,
                           format=cb_format)
         axins1.yaxis.set_ticks_position(tick_position)
         make_cbar_labels_readable(self.fig, axins1)
Ejemplo n.º 2
0
 def add_colorbar(self,
                  contour,
                  label=None,
                  tick_levels=None,
                  width="3%",
                  height="30%",
                  cb_format=None,
                  left=0.08,
                  right=0.95,
                  top=0.9,
                  bottom=0.14,
                  fraction=0.05,
                  pad=0.01,
                  loc=1,
                  tick_position="left"):
     if not self.noframe:
         self.fig.subplots_adjust(left=left,
                                  right=right,
                                  top=top,
                                  bottom=bottom)
         cbar = self.fig.colorbar(contour, fraction=fraction, pad=pad)
         cbar.set_label(label)
     else:
         axins1 = mpl_toolkits.axes_grid1.inset_locator.inset_axes(
             self.ax, width=width, height=height, loc=loc)
         self.fig.colorbar(contour,
                           cax=axins1,
                           orientation="vertical",
                           ticks=tick_levels,
                           format=cb_format)
         axins1.yaxis.set_ticks_position(tick_position)
         make_cbar_labels_readable(self.fig, axins1)