Image.colorbar#
- ColorbarManager.colorbar(pcm: QuadMesh | PathCollection | LineCollection | QuadContourSet | None = None, axs: Axes | int | None = None, cax: Axes | int | None = None, check: bool = True, **kwargs: Any) None[source]#
Display a colorbar in a selected position.
The colorbar will be placed next to the axis axs. If the keyword cax is enabled the colorbar is located in a specific axis, otherwise an axis will be shrunk in order to place the colorbar.
- Parameters:
- - axs: axis object, default None
The axes where the display that will be used for the colorbar is located. If None, the last considered axis will be used.
- - cax: axis object, default None
The axes where the colorbar should be placed. If None, the colorbar will be placed next to the axis axs.
- - clabel: str, default None
Sets the label of the colorbar.
- - cpad: float, default 0.07
Fraction of original axes between colorbar and the axes (in case cax is not defined).
- - cpos: {‘top’,’bottom’,’left’,’right’}, default ‘right’
Sets the position of the colorbar.
- - cticks: {[float], None}, default None
If enabled (and different from None), sets manually ticks on the colorbar.
- - ctickslabels: str, default None
If enabled, sets manually ticks labels on the colorbar.
- - extend: {‘neither’,’both’,’min’,’max’}, default ‘neither’
Sets the extension of the triangular colorbar extension.
- - extendrect: bool, default False
If True, the colorbar extension will be rectangular.
- - pcm: QuadMesh | PathCollection | None, default None
The collection to be used for the colorbar. If None, the axs will be used. If both pcm and axs are not None, pcm will be used.
- —-
- Returns:
- None
Examples
Example #1: create a standard colorbar on the right
>>> import pyPLUTO as pp >>> I = pp.Image() >>> I.display(var) >>> I.colorbar()
Example #2: create a colorbar in a different axis
>>> import pyPLUTO as pp >>> I = pp.Image() >>> ax = I.create_axes(ncol=2) >>> I.display(var, ax=ax[0]) >>> I.colorbar(axs=ax[0], cax=ax[1])
- Example #3: create a set of 3 displays with a colorbar on the bottom.
Another colorbar is shown on the right of the topmost display
>>> import pyPLUTO as pp >>> I = pp.Image() >>> ax = I.create_axes(nrow=4) >>> I.display(var1, ax=ax[0]) >>> I.colorbar(axs=ax[0]) >>> I.display(var2, ax=ax[1]) >>> I.display(var3, ax=ax[2]) >>> I.colorbar(axs=ax[2], cax=ax[3])