Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix legend #544

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

Merged
merged 6 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 12 fastplotlib/legends/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def __init__(
)

# for now only support lines with a single color
if np.unique(graphic.colors(), axis=0).shape[0] > 1:
if np.unique(graphic.colors.value, axis=0).shape[0] > 1:
raise ValueError("Use colorbars for multi-colored lines, not legends")

color = pygfx.Color(np.unique(graphic.colors(), axis=0).ravel())
color = pygfx.Color(np.unique(graphic.colors.value, axis=0).ravel())

self._parent = parent

Expand Down Expand Up @@ -117,7 +117,7 @@ def label(self, text: str):
self._label_world_object.geometry.set_text(text)

def _update_color(self, ev: FeatureEvent):
new_color = ev.pick_info["new_data"]
new_color = ev.info["value"]
if np.unique(new_color, axis=0).shape[0] > 1:
raise ValueError(
"LegendError: LineGraphic colors no longer appropriate for legend"
Expand All @@ -126,8 +126,8 @@ def _update_color(self, ev: FeatureEvent):
self._color = new_color[0]
self._line_world_object.material.color = pygfx.Color(self._color)

def _highlight_graphic(self, graphic, ev):
graphic_color = pygfx.Color(np.unique(graphic.colors(), axis=0).ravel())
def _highlight_graphic(self, graphic: Graphic, ev):
graphic_color = pygfx.Color(np.unique(graphic.colors.value, axis=0).ravel())

if graphic_color == self._parent.highlight_color:
graphic.colors = self._color
Expand Down Expand Up @@ -270,7 +270,7 @@ def add_graphic(self, graphic: Graphic, label: str = None):
self._graphics.append(graphic)
self._items[graphic._fpl_address] = legend_item

graphic.deleted.add_event_handler(partial(self.remove_graphic, graphic))
graphic.add_event_handler(partial(self.remove_graphic, graphic), "deleted")

self._col_counter = new_col_ix
self._row_counter = new_row_ix
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.