tight_colorbar¶
- msaexp.utils.tight_colorbar(color_result, fig, ax, sx=0.325, sy=0.03, loc='ul', pad=0.01, location=None, label=None, bbox_kwargs=None, zorder=100, label_format=None, labelsize=8, colorbar_alpha=None, **kwargs)[source]¶
Insert a colorbar at the corners/edges of a plot axis
- Parameters
- color_resultobject
Something that can generate a colorbar, e.g.,
color_result = ax.scatter(x, y, c=z, vmin=0, vmax=1, cmap='viridis').- fig
matplotlib.figure.Figure Figure object
- ax
matplotlib.axes.Axes Axis to define the positioning of the colorbar
- sx, syfloat
x and y size of the colorbar. If
sx < sy, will draw the colorbar oriented vertically. The larger of the two inputs is taken as the color bar length and has units of the size ofax. The smaller value is the color bar width and has units of the full figure size along that dimension. For example, the defaults ofsx = 0.325andsy = 0.03will result in a horizonal colorbar about 1/3 of the width of the plot axis and 3% of the full figure size.- locstr
Two-character string specifying the vertical (
u``pper, ``c``enter, ``l``ower) and horizontal (``l``eft, ``c``enter, ``r``ight) location of the anchor of the colorbar axis. The default ``ulis the “upper left” corner.- padfloat
Padding to add relative to the
locposition.- locationstr
Label location to override the internal calculation (“top”, “bottom” , “left”, “right”).
- labelstr
Label of the colorbar
- bbox_kwargsdict
Keyword arguments of a box to draw around the colorbar and its associated labels, e.g., to visually raise it over overlapping background points in the plot axis.
- zordernumber
zorder of the colorbar axis added to the figure
- label_formatstr
String formatting of the colorbar tick labels, e.g., “%.1f”.
- labelsizefloat
Font size of the colorbar labels
- colorbar_alphafloat
Transparency to use for the colorbar itself, which can be different than the transparency used for the data plotted in
color_result.
- Returns
- cax
matplotlib.axes.Axes Colorbar axis
- cb
matplotlib.colorbar.Colorbar Colorbar object
- cax