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

beginning base logic for interactivity impl #61

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

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
LineCollection has @world_object, fix float64 bug in LineGraphic
  • Loading branch information
kushalkolar committed Dec 21, 2022
commit a6b53ee89e78e04f25ce53e15922384902965d11
223 changes: 139 additions & 84 deletions 223 examples/linecollection_event.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 2 fastplotlib/graphics/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, data: np.ndarray, z_position: float = None, size: float = 2.0
def fix_data(self):
# TODO: data should probably be a property of any Graphic?? Or use set_data() and get_data()
if self.data.ndim == 1:
self.data = np.dstack([np.arange(self.data.size), self.data])[0]
self.data = np.dstack([np.arange(self.data.size), self.data])[0].astype(np.float32)

if self.data.shape[1] != 3:
if self.data.shape[1] != 2:
Expand Down
23 changes: 19 additions & 4 deletions 23 fastplotlib/graphics/linecollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
from abc import ABC, abstractmethod


class LineCollection():
def __init__(self, data: List[np.ndarray], z_position: Union[List[float], float] = None, size: Union[float, List[float]] = 2.0, colors: Union[List[np.ndarray], np.ndarray] = None,
cmap: Union[List[str], str] = None, *args, **kwargs):
class LineCollection:
def __init__(self, data: List[np.ndarray],
z_position: Union[List[float], float] = None,
size: Union[float, List[float]] = 2.0,
colors: Union[List[np.ndarray], np.ndarray] = None,
cmap: Union[List[str], str] = None,
*args,
**kwargs):

self.name = None

if not isinstance(z_position, float) and z_position is not None:
if not len(data) == len(z_position):
Expand All @@ -26,6 +33,7 @@ def __init__(self, data: List[np.ndarray], z_position: Union[List[float], float]
raise ValueError("args must be the same length")

self.data = list()
self._world_object = pygfx.Group()

for i, d in enumerate(data):
if isinstance(z_position, list):
Expand All @@ -48,7 +56,14 @@ def __init__(self, data: List[np.ndarray], z_position: Union[List[float], float]
else:
_cmap = cmap

self.data.append(LineGraphic(d, _z, _size, _colors, _cmap))
lg = LineGraphic(d, _z, _size, _colors, _cmap)
self.data.append(lg)
self._world_object.add(lg.world_object)

# TODO: make a base class for Collection graphics and put this as a base method
@property
def world_object(self) -> pygfx.WorldObject:
return self._world_object

@property
def features(self) -> List[str]:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.