Skip to content

Commit 0970d8c

Browse files
authored
Merge pull request #14 from scipp/fix-scatter-shader
Fix scatter plot for varying sizes and colors
2 parents 6a47714 + c710b9b commit 0970d8c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/matplotgl/points.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def __init__(
8787
self._yscale = yscale
8888
self._zorder = zorder
8989

90-
self._geometry = p3.BufferGeometry(
91-
attributes={"position": p3.BufferAttribute(array=self._make_positions())}
92-
)
90+
geometry_attributes = {
91+
"position": p3.BufferAttribute(array=self._make_positions())
92+
}
9393

9494
if not isinstance(c, str) or not np.isscalar(s) or marker != "s":
9595
if isinstance(c, str):
@@ -110,7 +110,7 @@ def __init__(
110110
else:
111111
sizes = np.asarray(s, dtype=np.float32)
112112

113-
self._geometry.attributes.update(
113+
geometry_attributes.update(
114114
{
115115
"customColor": p3.BufferAttribute(array=colors),
116116
"size": p3.BufferAttribute(array=sizes),
@@ -125,6 +125,7 @@ def __init__(
125125
else:
126126
self._material = p3.PointsMaterial(color=cm.to_hex(c), size=s)
127127

128+
self._geometry = p3.BufferGeometry(attributes=geometry_attributes)
128129
self._points = p3.Points(geometry=self._geometry, material=self._material)
129130

130131
def _make_positions(self) -> np.ndarray:

0 commit comments

Comments
 (0)