Skip to content

Commit

Permalink
vispy viewer: fix legend
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Dec 23, 2020
1 parent 7264e75 commit aa27334
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions navis/plotting/vispy/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,15 @@ def update_legend(self):
labels[s].parent = None

# Generate new labels
to_add = [s for s in _neuron_obj if s not in labels]
to_add = [s for s in neuron_obj if s not in labels]
for s in to_add:
# Fallback is name or in lieu of that the object's type
lbl = getattr(_neuron_obj[s][0], '_name',
str(type(_neuron_obj[s][0])))
lbl = getattr(neuron_obj[s][0], '_name',
str(type(neuron_obj[s][0])))
# See if we find a "label" property
if hasattr(_neuron_obj[s][0], '_object'):
if hasattr(_neuron_obj[s][0]._object, 'label'):
lbl = _neuron_obj[s][0]._object.label
if hasattr(neuron_obj[s][0], '_object'):
if hasattr(neuron_obj[s][0]._object, 'label'):
lbl = neuron_obj[s][0]._object.label

txt = scene.visuals.Text(lbl,
anchor_x='left',
Expand All @@ -550,15 +550,15 @@ def update_legend(self):
txt.interactive = True
txt.unfreeze()
txt._object_id = s
txt._id = _neuron_obj[s][0]._id
txt._id = neuron_obj[s][0]._id
txt.freeze()

# Position and color labels
labels = {l._object_id: l for l in self.overlay.children if getattr(
l, '_object_id', None)}
for i, s in enumerate(sorted(_neuron_obj)):
if _neuron_obj[s][0].visible:
color = _neuron_obj[s][0].color
for i, s in enumerate(sorted(neuron_obj)):
if neuron_obj[s][0].visible:
color = neuron_obj[s][0].color
else:
color = (.3, .3, .3)

Expand Down

0 comments on commit aa27334

Please sign in to comment.