You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-1Lines changed: 30 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,8 @@ npm -i regl-scatterplot
34
34
35
35
## Getting started
36
36
37
+
#### Basic Example
38
+
37
39
```javascript
38
40
importcreateScatterplotfrom'regl-scatterplot';
39
41
@@ -55,7 +57,34 @@ const points = new Array(10000)
55
57
scatterplot.draw(points);
56
58
```
57
59
58
-
See a complete example at [example/index.js](example/index.js).
60
+
#### Color by value or category
61
+
62
+
Regl-scatterplot supports two color modes: coloring by value or coloring by category. To support those, each point can be associated to a categorical and continuous value. To specify those values simply append two additional values to a point quadruples: e.g., `[x, y, category, value]`.
63
+
64
+
```javascript
65
+
scatterplot.draw([
66
+
// x, y, category, value
67
+
0.2, -0.1, 0, 0.1337,
68
+
0.3, 0.1, 0, 0.3371,
69
+
-0.9, 0.8, 1, 0.3713,
70
+
]);
71
+
```
72
+
73
+
To color points by category, set `pointColor` to a list of colors. For performance reasons, regl-scatterplot assumes that the category `0` refers to the first color, `1` refers to the second color, etc. Mathematically, regl-scatterplot maps categories to colors as follows: `category => category % colors.length`.
To apply a continuous colormap use `colorBy: 'value'` and set `pointColor` to a list of colors representing the colormap. For performance reasons, regl-scatterplot assumes that the values are in `[0,1]` . Mathematically, the maping functions is as follows: `value => Math.min(1, Math.max(0, value))`.
0 commit comments