Skip to content

Commit 78ba878

Browse files
committed
document Plot.scale(projection)
1 parent 8957bff commit 78ba878

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

docs/features/scales.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,3 +1065,16 @@ As another example, below are two plots with different options where the second
10651065
const plot1 = Plot.plot({...options1});
10661066
const plot2 = Plot.plot({...options2, color: plot1.scale("color")});
10671067
```
1068+
1069+
Plot.scale also supports projections. <VersionBadge version="0.6.18" /> The returned projection object exposes *apply* and *invert* methods for converting between geographic and pixel coordinates, and can be passed as the **projection** option of another plot.
1070+
1071+
```js
1072+
const projection = Plot.scale({projection: {type: "mercator"}});
1073+
projection.apply([-1.55, 47.22]) // [316.7, 224.2]
1074+
```
1075+
1076+
The projection's **width** defaults to 640, and its **height** defaults to the width times the projection's natural aspect ratio. You can override these with the **width** and **height** options, and inset the projection with the **margin** and **inset** options.
1077+
1078+
```js
1079+
const projection = Plot.scale({projection: {type: "albers-usa", domain, width: 960, height: 600}});
1080+
```

0 commit comments

Comments
 (0)