legendkit.colorbar¶
- class legendkit.colorbar(mappable=None, norm=None, cmap=None, *, ax: Axes = None, style: str = 'white', shape: str = 'rect', width: float = None, height: float = None, loc=None, deviation=0.05, bbox_to_anchor: Any = None, bbox_transform: Any = None, axes_class: Any = None, axes_kwargs: Any = None, borderpad: Any = 0, orientation: str = 'vertical', title: str = None, alignment: str = 'left', title_fontproperties: Dict = None, **colorbar_options)¶
Colorbar based on Axes
For other parameters, see colorbar <matplotlib.color.Colorbar>
- Parameters:
- mappable
ScalarMapping The mappable whose colormap and norm will be used.
- norm
Normalize The normalization to use.
- cmap
Colormap The colormap to use.
- ax
Axes The axes to draw colorbar.
- style{‘white’, ‘normal’}, default: ‘white’
- widthfloat
The width of colorbar
- heightfloat
The height of colorbar
- locstr
Apart from the default location code, you can add ‘out’ as prefix to place the legend ouside the axes. See all available options.
- deviationfloat
The space between colorbar and axes if place outside
- bbox_to_anchor
- bbox_transform
- axes_class
- axes_kwargs
- borderpad
- orientation{‘vertical’, ‘horizontal’}
The orientation of the colorbar
- titlestr
The title of colorbar
- alignment{‘left’, ‘right’, ‘center’}, default: ‘center’
The alignment of title and colorbar
- title_fontproperties
- colorbar_optionsmapping
Pass to
matplotlib.colorbar.Colorbar
- mappable
Examples
>>> from legendkit import colorbar >>> data = np.random.rand(10, 10) >>> mp = plt.pcolormesh(data, cmap="RdBu") >>> colorbar(mp)