Skip to content

Commit 320bb7b

Browse files
committed
plot
1 parent eb01855 commit 320bb7b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

docs/lib/plot.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
# Observable Plot
22

3+
[Observable Plot](https://observablehq.com/plot/) is a JavaScript library for exploratory data visualization, made by the same team as [D3](d3). It is available by default as `Plot` in Markdown, but you can import it explicitly like so:
4+
35
```js echo
46
import * as Plot from "npm:@observablehq/plot";
57
```
68

7-
```js echo
9+
To display a chart in Observable markdown, simply call Plot in a JavaScript code block:
10+
11+
````md
12+
```js
813
Plot.frame().plot()
914
```
15+
````
16+
17+
For example, here’s a Voronoi chart:
18+
19+
```js echo
20+
const random = d3.randomLcg(42);
21+
const chart = Plot.voronoi(Array.from({length: 100}, () => [random(), random()])).plot({nice: true});
22+
23+
display(chart);
24+
```
25+
26+
Or, to include a ${Plot.lineY([1,2,0,4,0,3,1,5,7,2,3]).plot({axis: null, width: 80, height: 18})} sparkline in your text —or bars ${Plot.barY([1,2,4,3,1,5], {fill: Plot.identity}).plot({axis: null, width: 80, height: 18})}— just call:
27+
28+
```md
29+
… include a ${Plot.lineY([1,2,0,4,0,3,1,5,7,2,3]).plot({axis: null, width: 80, height: 18})} sparkline…
30+
… bars ${Plot.lineY([1,2,4,3,1,5], {fill: Plot.identity}).plot({axis: null, width: 80, height: 18})}— just…
31+
```

0 commit comments

Comments
 (0)