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

Commit 7352fac

Browse filesBrowse files
committed
rename zlevel to z_position, it now adjusts world_object.position instead of the actual data
1 parent b286aa5 commit 7352fac
Copy full SHA for 7352fac

File tree

3 files changed

+16
-20
lines changed
Filter options

3 files changed

+16
-20
lines changed

‎fastplotlib/graphics/line.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/line.py
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66

77
class LineGraphic(Graphic):
8-
def __init__(self, data: np.ndarray, zlevel: float = None, size: float = 2.0, colors: np.ndarray = None, cmap: str = None, *args, **kwargs):
8+
def __init__(self, data: np.ndarray, z_position: float = 0.0, size: float = 2.0, colors: np.ndarray = None, cmap: str = None, *args, **kwargs):
99
super(LineGraphic, self).__init__(data, colors=colors, cmap=cmap, *args, **kwargs)
1010

11-
self.zlevel = zlevel
12-
1311
self.fix_data()
1412

1513
if size < 1.1:
@@ -24,6 +22,8 @@ def __init__(self, data: np.ndarray, zlevel: float = None, size: float = 2.0, co
2422
material=material(thickness=size, vertex_colors=True)
2523
)
2624

25+
self.world_object.position.z = z_position
26+
2727
def fix_data(self):
2828
# TODO: data should probably be a property of any Graphic?? Or use set_data() and get_data()
2929
if self.data.ndim == 1:
@@ -32,12 +32,9 @@ def fix_data(self):
3232
if self.data.shape[1] != 3:
3333
if self.data.shape[1] != 2:
3434
raise ValueError("Must pass 1D, 2D or 3D data")
35-
# make it 2D with zlevel
36-
if self.zlevel is None:
37-
self.zlevel = 0
3835

39-
# zeros
40-
zs = np.full(self.data.shape[0], fill_value=self.zlevel, dtype=np.float32)
36+
# zeros for z
37+
zs = np.zeros(self.data.shape[0], dtype=np.float32)
4138

4239
self.data = np.dstack([self.data[:, 0], self.data[:, 1], zs])[0]
4340

‎fastplotlib/graphics/linecollection.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/linecollection.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77

88
class LineCollection():
9-
def __init__(self, data: List[np.ndarray], zlevel: Union[List[float], float] = None, size: Union[float, List[float]] = 2.0, colors: Union[List[np.ndarray], np.ndarray] = None,
9+
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,
1010
cmap: Union[List[str], str] = None, *args, **kwargs):
1111

12-
if not isinstance(zlevel, float) and zlevel is not None:
13-
if not len(data) == len(zlevel):
12+
if not isinstance(z_position, float) and z_position is not None:
13+
if not len(data) == len(z_position):
1414
raise ValueError("args must be the same length")
1515
if not isinstance(size, float):
1616
if not len(size) == len(data):
@@ -25,10 +25,10 @@ def __init__(self, data: List[np.ndarray], zlevel: Union[List[float], float] = N
2525
self.collection = list()
2626

2727
for i, d in enumerate(data):
28-
if isinstance(zlevel, list):
29-
_zlevel = zlevel[i]
28+
if isinstance(z_position, list):
29+
_z = z_position[i]
3030
else:
31-
_zlevel = zlevel
31+
_z = z_position
3232

3333
if isinstance(size, list):
3434
_size = size[i]
@@ -45,7 +45,7 @@ def __init__(self, data: List[np.ndarray], zlevel: Union[List[float], float] = N
4545
else:
4646
_cmap = cmap
4747

48-
self.collection.append(LineGraphic(d, _zlevel, _size, _colors, _cmap))
48+
self.collection.append(LineGraphic(d, _z, _size, _colors, _cmap))
4949

5050
def __getitem__(self, item):
5151
return self.collection[item]

‎fastplotlib/graphics/scatter.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/scatter.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class ScatterGraphic(Graphic):
10-
def __init__(self, data: np.ndarray, zlevel: float = None, size: int = 1, colors: np.ndarray = None, cmap: str = None, *args, **kwargs):
10+
def __init__(self, data: np.ndarray, z_position: float = 0.0, size: int = 1, colors: np.ndarray = None, cmap: str = None, *args, **kwargs):
1111
super(ScatterGraphic, self).__init__(data, colors=colors, cmap=cmap, *args, **kwargs)
1212

1313
if self.data.ndim == 1:
@@ -16,12 +16,9 @@ def __init__(self, data: np.ndarray, zlevel: float = None, size: int = 1, colors
1616
raise ValueError("If passing single you must specify all coordinates, i.e. x, y and z.")
1717
elif self.data.shape[1] != 3:
1818
if self.data.shape[1] == 2:
19-
# make it 2D with zlevel
20-
if zlevel == None:
21-
zlevel = 0
2219

2320
# zeros
24-
zs = np.full(self.data.shape[0], fill_value=zlevel, dtype=np.float32)
21+
zs = np.zeros(self.data.shape[0], dtype=np.float32)
2522

2623
self.data = np.dstack([self.data[:, 0], self.data[:, 1], zs])[0]
2724
if self.data.shape[1] > 3 or self.data.shape[1] < 1:
@@ -43,6 +40,8 @@ def __init__(self, data: np.ndarray, zlevel: float = None, size: int = 1, colors
4340
self.world_object.add(points)
4441
self.points_objects.append(points)
4542

43+
self.world_object.position.z = z_position
44+
4645
def _process_positions(self, positions: np.ndarray):
4746
if positions.ndim == 1:
4847
positions = np.array([positions])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.