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: CHANGELOG.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,9 @@ A new [**facetAnchor**](#facetanchor) option, available for all marks, controls
28
28
29
29
A new **anchor** option allows to draw only one side of the [frame](./README.md#frame) mark—in which case the **fill**, **fillOpacity**, **rx**, and **ry** options are ignored.
30
30
31
-
* Fixed a crash of the [raster](./README.md#raster) when the colors use the identity scale (https://github.com/observablehq/plot/issues/1237)
31
+
The new [auto mark](./README.md#auto) automatically selects a mark type that best represents the dimensions of the given data according to some simple heuristics. For example, `Plot.auto(olympians, {x: "height", y: "weight"}).plot()` makes a scatterplot; `Plot.auto(aapl, {x: "Date", y: "Close"}).plot()` makes a line chart; `Plot.auto(penguins, {x: "body_mass_g"}).plot()` makes a histogram; `Plot.auto(penguins, {x: "island"}).plot()` makes a bar chart.
32
+
33
+
* Fix a crash of the [raster](./README.md#raster) when the colors use the identity scale (https://github.com/observablehq/plot/issues/1237)
32
34
* New sideEffects worth mentioning? https://github.com/observablehq/plot/pull/1235
Copy file name to clipboardExpand all lines: README.md
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -964,6 +964,69 @@ Returns a new arrow with the given *data* and *options*.
964
964
965
965
<!-- jsdocEnd arrow -->
966
966
967
+
### Auto
968
+
969
+
[Source](./src/marks/auto.js) · [Examples](https://observablehq.com/@observablehq/plot-auto) · Automatically selects a mark type that best represents the dimensions of the given data according to some simple heuristics. While Plot.auto will respect the options you provide, you shouldn’t rely on Plot.auto’s behavior being stable over time; if you want to guarantee a specific chart type, you should specify the marks and transforms explicitly. Plot.auto is intended to support fast exploratory analysis where the goal is to get a useful plot as quickly as possible.
970
+
971
+
For example, two quantitative dimensions make a scatterplot:
// equivalent to Plot.dot(olympians, {x: "height", y: "weight"}).plot()
976
+
```
977
+
978
+
A monotonic quantitative dimension and another numeric one make a line chart:
979
+
980
+
```js
981
+
Plot.auto(aapl, {x:"Date", y:"Close"}).plot()
982
+
// equivalent to Plot.lineY(aapl, {x: "Date", y: "Close"}).plot()
983
+
```
984
+
985
+
One quantitative dimension makes a histogram:
986
+
987
+
```js
988
+
Plot.auto(penguins, {x:"body_mass_g"}).plot()
989
+
// equivalent to Plot.rectY(penguins, Plot.binX({y: "count"}, {x: "body_mass_g"})).plot()
990
+
```
991
+
992
+
One ordinal dimension makes a bar chart:
993
+
994
+
```js
995
+
Plot.auto(penguins, {x:"island"}).plot()
996
+
// equivalent to Plot.barY(penguins, Plot.groupX({y: "count"}, {x: "island"})).plot()
997
+
```
998
+
999
+
Opinionated inferences also make it easier to switch which dimensions you’re showing by changing only one thing in the code: you can switch a vertical bar chart to a horizontal one by just switching x to y, instead of also having to switch Plot.barY to Plot.barX and Plot.groupX to Plot.groupY.
1000
+
1001
+
The options are six channels and a mark override. You must specify either x or y; all others are optional:
1002
+
* **x** - corresponds to each mark’s _x_ channel; if specified without _y_, bins or groups on _x_ and shows the count on _y_
1003
+
* **y** - corresponds to each mark’s _y_ channel; if specified without _x_, bins or groups on _y_ and shows the count on _x_
1004
+
* **fx** - corresponds to each mark’s _fx_ channel
1005
+
* **fy** - corresponds to each mark’s _fy_ channel
1006
+
* **color** - corresponds to stroke (for line, rule, dot) or fill (for area, rect, bar, cell)
1007
+
* **size** - corresponds to the dot’s _r_ channel; setting this always results in a dot mark
1008
+
* **mark** - dot, line, area, rule, or bar; each option except dot includes x and y variants, and bar tries picks the appropriate mark from barX, barY, rectX, rectY, rect, or cell
1009
+
1010
+
The six channels take one of the following:
1011
+
* a string; if not a valid CSS color string or reducer name, interpreted as a field name
1012
+
* an accessor function
1013
+
* an object _{value, reduce, color}_, where _value_ is a field string or accessor, _reduce_ is a reducer name or function, and _color_ is a color string
1014
+
1015
+
Setting a reducer on **x** or **y** implicitly groups or bins on the other (y or x). Setting a reducer on **color** or **size** groups or bins in both x and y dimensions. Setting a reducer on both x and y throws an error.
// equivalent to Plot.rect(athletes, Plot.bin({fill: "count"}, {x: "height", y: "weight"})).plot()
1024
+
```
1025
+
1026
+
Returns an automatically selected mark with the given *data* and *options* for a quick view of the data. The heuristic for the choice may evolve in the future.
1027
+
1028
+
<!-- jsdocEnd auto -->
1029
+
967
1030
### Axis
968
1031
969
1032
[Source](./src/marks/axis.js) · [Examples](https://observablehq.com/@observablehq/plot-axis) · Draws an axis to document the visual encoding of the corresponding position scale: *x* or *y*, and *fx* or *fy* if faceting. The axis mark is a [composite mark](#marks) comprised of (up to) three marks: a [vector](#vector) for ticks, a [text](#text) for tick labels, and another [text](#text) for an axis label.
0 commit comments