diff --git a/vispy/scene/widgets/colorbar.py b/vispy/scene/widgets/colorbar.py index 355f55df1a..0230fb425e 100644 --- a/vispy/scene/widgets/colorbar.py +++ b/vispy/scene/widgets/colorbar.py @@ -78,7 +78,7 @@ def __init__(self, cmap, orientation, self._colorbar = ColorBarVisual(size=dummy_size, cmap=cmap, orientation=orientation, - label_str=label, clim=clim, + label_text=label, clim=clim, label_color=label_color, border_width=border_width, border_color=border_color, **kwargs) diff --git a/vispy/visuals/colorbar.py b/vispy/visuals/colorbar.py index 80d02fbb78..e8ad662ef5 100644 --- a/vispy/visuals/colorbar.py +++ b/vispy/visuals/colorbar.py @@ -255,7 +255,7 @@ class ColorBarVisual(CompoundVisual): pos : tuple (x, y) Position where the colorbar is to be placed with respect to the center of the colorbar - label_str : str + label_text : str The label that is to be drawn with the colorbar that provides information about the colorbar. label_color : str | vispy.color.Color @@ -280,14 +280,13 @@ class ColorBarVisual(CompoundVisual): def __init__(self, cmap, orientation, size, pos=[0, 0], - label_str="", + label_text="", label_color='black', clim=(0.0, 1.0), border_width=1.0, border_color="black", **kwargs): - self._label_str = label_str self._label_color = label_color self._cmap = get_colormap(cmap) self._clim = clim @@ -295,7 +294,7 @@ def __init__(self, cmap, orientation, size, self._size = size self._orientation = orientation - self._label = TextVisual(self._label_str, color=self._label_color) + self._label = TextVisual(label_text, color=self._label_color) self._ticks = [] self._ticks.append(TextVisual(str(self._clim[0]), @@ -597,7 +596,10 @@ def label(self): @label.setter def label(self, label): - self._label = label + if isinstance(label, str): + self._label.text = label + else: + self._label = label self._update() @property