Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding setter for colorbar's label_str #1292

Closed
wants to merge 12 commits into from
2 changes: 1 addition & 1 deletion vispy/scene/widgets/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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)
Expand Down
12 changes: 7 additions & 5 deletions vispy/visuals/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,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
Expand All @@ -277,22 +277,21 @@ 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
self._pos = pos
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]),
Expand Down Expand Up @@ -601,7 +600,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
Expand Down