class visbrain.objects.ColorbarObj(name, rect=(-0.7, -2, 1.5, 4), transform=None, parent=None, verbose=None, **kwargs)[source][source]

Create a colorbar object.

name : str

Name of the colorbar object. Alternatively, you can pass an other object (like BrainObj or SourceObj) to get their colorbar.

rect : tuple | (-.7, -2, 1.5, 4)

Camera rectangle. The rect input must be a tuple of four floats describing where the camera (start_x, start_y, length_x, length_y).

cmap : string | None

Matplotlib colormap (like ‘viridis’, ‘inferno’…).

clim : tuple/list | None

Colorbar limit. Every values under / over clim will clip.

isvmin : bool | False

Activate/deactivate vmin.

vmin : float | None

Every values under vmin will have the color defined using the under parameter.

vmax : float | None

Every values over vmin will have the color defined using the over parameter.

under : tuple/string | None

Matplotlib color under vmin.

over : tuple/string | None

Matplotlib color over vmax.

cblabel : string | ‘’

Colorbar label.

cbtxtsz : float | 5..

Text size of the colorbar label.

cbtxtsh : float | 2.3

Shift for the colorbar label.

txtcolor : string | ‘white’

Text color.

txtsz : float | 3.

Text size for clim/vmin/vmax text.

txtsh : float | 1.2

Shift for clim/vmin/vmax text.

border : bool | True

Display colorbar borders.

bw : float | 2.

Border width.

limtxt : bool | True

Display vmin/vmax text.

bgcolor : tuple/string | (0., 0., 0.)

Background color of the colorbar canvas.

ndigits : int | 2

Number of digits for the text.

width : float | 0.17

Colorbar width.

transform : VisPy.visuals.transforms | None

VisPy transformation to set to the parent node.

parent : VisPy.parent | None

Markers object parent.

verbose : string

Verbosity level.


List of supported shortcuts :

  • s : save the figure
  • <delete> : reset camera


>>> from visbrain.objects import ColorbarObj
>>> cb = ColorbarObj('cbar', cmap='viridis', clim=(4., 78.2), vmin=10.,
>>>                  vmax=72., cblabel='Colorbar title', under='gray',
>>>                  over='red', txtcolor='black', cbtxtsz=40, cbtxtsh=2.,
>>>                  txtsz=20., width=.04)
>>> cb.preview()


__init__(name[, rect, transform, parent, …]) Init.
describe_tree() Tree description.
preview([bgcolor, axis, xyz, show, obj, size]) Previsualize the result.
screenshot(saveas[, print_size, dpi, unit, …]) Take a screeshot of the scene.
set_shortcuts_to_canvas(canvas) Set shortcuts to a VisbrainCanvas.
to_dict() Return a dictionary of all colorbar args.
to_kwargs([addisminmax]) Return a dictionary for input arguments.
update() Fonction to run when an update is needed.
update_from_dict(kwargs) Update attributes from a dictionary.

Get the cmap value.


Get the name value.


Get the parent value.

preview(bgcolor='black', axis=False, xyz=False, show=True, obj=None, size=(1200, 800), **kwargs)[source]

Previsualize the result.

bgcolor : array_like/string/tuple | ‘black’

Background color for the preview.

axis : bool | False

Add x and y axis with ticks.

xyz : bool | False

Add an (x, y, z) axis to the scene.

obj : VisbrainObj | None

Pass a Visbrain object if you want to use the camera of an other object.

size : tuple | (1200, 800)

Default size of the window.

kwargs : dict | {}

Optional arguments are passed to the VisbrainCanvas class.

screenshot(saveas, print_size=None, dpi=300.0, unit='centimeter', factor=None, region=None, autocrop=False, bgcolor=None, transparent=False, obj=None, line_width=1.0, **kwargs)[source]

Take a screeshot of the scene.

By default, the rendered canvas will have the size of your screen. The screenshot() method provides two ways to increase to exported image resolution :

  • Using print_size, unit and dpi inputs : specify the size of the image at a specific dpi level. For example, you might want to have an (10cm, 15cm) image at 300 dpi.
  • Using the factor input : multiply the default image size by this factor. For example, if you have a (1920, 1080) monitor and if factor is 2, the exported image should have a shape of (3840, 2160) pixels.
saveas : str

The name of the file to be saved. This file must contains a extension like .png, .tiff, .jpg…

print_size : tuple | None

The desired print size. This argument should be used in association with the dpi and unit inputs. print_size describe should be a tuple of two floats describing (width, height) of the exported image for a specific dpi level. The final image might not have the exact desired size but will try instead to find a compromize regarding to the proportion of width/height of the original image.

dpi : float | 300.

Dots per inch for printing the image.

unit : {‘centimeter’, ‘millimeter’, ‘pixel’, ‘inch’}

Unit of the printed size.

factor : float | None

If you don’t want to use the print_size input, factor simply multiply the resolution of your screen.

region : tuple | None

Select a specific region. Must be a tuple of four integers each one describing (x_start, y_start, width, height).

autocrop : bool | False

Automaticaly crop the figure in order to have the smallest space between the brain and the border of the picture.

bgcolor : array_like/string | None

The background color of the image.

transparent : bool | False

Specify if the exported figure have to contains a transparent background.

obj : VisbrainObj | None

Pass a Visbrain object if you want to use the camera of an other object for the sceen rendering.

kwargs : dict | {}

Optional arguments are passed to the VisbrainCanvas class.


Get the transform value.


Get the visible_obj value.