fsleyes_widgets.utils.colourbarbitmap¶
This module provides a single function, colourBarBitmap(), which uses
matplotlib to plot a colour bar. The colour bar is rendered off-screen
and returned as an RGBA bitmap.
-
fsleyes_widgets.utils.colourbarbitmap.colourBarBitmap(cmap, width, height, cmapResolution=256, negCmap=None, invert=False, gamma=1, ticks=None, ticklabels=None, tickalign=None, label=None, orientation='vertical', labelside='top', alpha=1.0, fontsize=10, bgColour=None, textColour='#ffffff', scale=1.0)[source]¶ Plots a colour bar using
matplotlib.The rendered colour bar is returned as a RGBA bitmap within a
numpy.uint8array of size \(w \times h \times 4\), with the top-left pixel located at index[0, 0, :].A rendered colour bar will look something like this:
- Parameters
cmap – Name of a registered
matplotlibcolour map.width – Colour bar width in pixels.
height – Colour bar height in pixels.
cmapResolution – Colour map resolution (number of distinct colours).
negCmap – If provided, two colour maps are drawn, centered at 0.
invert – If
True, the colour map is inverted.gamma – Gamma correction factor - exponentially weights the colour map scale towards one end.
ticks – Locations of tick labels. Ignored if
ticklabels is None.ticklabels – Tick labels.
tickalign – Tick alignment (one for each tick, either
'left','right', or'center').label – Text label to show next to the colour bar.
orientation – Either
verticalorhorizontal.labelside – Side of the colour bar to put the label -
top,bottom,leftorright. Iforientation='vertical', thentop/bottomare interpreted asleft/right(and vice-versa whenorientation='horizontal').alpha – Colour bar transparency, in the range
[0.0 - 1.0].fontsize – Label font size in points.
bgColour – Background colour - can be any colour specification that is accepted by
matplotlib.textColour – Label colour - can be any colour specification that is accepted by
matplotlib.scale – DPI scaling factor.