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
+6-12Lines changed: 6 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,41 +4,39 @@
4
4
5
5
*Not yet released. These are forthcoming changes in the main branch.*
6
6
7
-
The new [auto mark](./README.md#auto) (Plot.auto) automatically selects a mark type that best represents the dimensions of the given data according to some simple heuristics. The auto mark is intended to support fast exploratory analysis where the goal is to get a useful plot as quickly as possible. It’s also great if you’re new to Plot, since you can get started with a minimal API.
8
-
9
-
For example,
7
+
The new [auto mark](./README.md#auto) ([Plot.auto](./README.md#plotautodata-options)) automatically selects a mark type that best represents the dimensions of the given data according to some simple heuristics. The auto mark is intended to support fast exploratory analysis where the goal is to get a useful plot as quickly as possible. It’s also great if you’re new to Plot, since you can get started with a minimal API. For example,
makes a scatterplot (equivalent to [Plot.dot](./README.md#dot));
15
+
makes a scatterplot (equivalent to [dot](./README.md#dot));
18
16
19
17
[TK image]
20
18
21
19
```js
22
20
Plot.auto(aapl, {x:"Date", y:"Close"}).plot()
23
21
```
24
22
25
-
makes a line chart (equivalent to [Plot.lineY](./README.md#line); this mark is chosen because the selected *x* dimension *Date* is temporal and monotonic, _i.e._, the data is in chronological order);
23
+
makes a line chart (equivalent to [lineY](./README.md#line); chosen because the selected *x* dimension *Date* is temporal and monotonic, _i.e._, the data is in chronological order);
26
24
27
25
[TK image]
28
26
29
27
```js
30
28
Plot.auto(penguins, {x:"body_mass_g"}).plot()
31
29
```
32
30
33
-
makes a histogram (equivalent to [Plot.rectY](./README.md#rect) and [Plot.binX](./README.md#bin); chosen because the _body_mass_g_ column is quantitative);
31
+
makes a histogram (equivalent to [rectY](./README.md#rect) and [binX](./README.md#bin); chosen because the _body_mass_g_ column is quantitative);
34
32
35
33
[TK image]
36
34
37
35
```js
38
36
Plot.auto(penguins, {x:"island"}).plot()
39
37
```
40
38
41
-
makes a bar chart (equivalent to [Plot.barY](./README.md#bar) and [Plot.groupX](./README.md#group); chosen because the _island_ column is categorical strings).
39
+
makes a bar chart (equivalent to [barY](./README.md#bar) and [groupX](./README.md#group); chosen because the _island_ column is categorical).
42
40
43
41
Plot’s [axes](./README.md#axis) and [grids](./README.md#axis) are now proper marks, affording a high degree of customizability. This has been one of our most asked-for features, closing more than a dozen feature requests!
44
42
@@ -52,11 +50,7 @@ Marks can now declare default margins via the **marginTop**, **marginRight**, **
52
50
53
51
The new [*mark*.**facetAnchor**](#facetanchor) mark option controls the facets in which the mark will appear when faceting. It defaults to null for all marks except for axis marks, where it defaults to *top-empty* if the axis anchor is *top*, *right-empty* if anchor is *right*, *bottom-empty* if anchor is *bottom*, and *left-empty* if anchor is *left*. This ensures the proper positioning of the axes with respect to empty facets.
54
52
55
-
The [frame mark](./README.md#frame)’s new **anchor** option allows you to draw a line on one side of the frame (as opposed to the default behavior where a rect is drawn around all four sides). This feature is now used by the *scale*.**line** option for *x* and *y* scales.
56
-
57
-
The [text mark](./README.md#text) now supports soft hyphens (`\xad`); lines are now eligible to break at soft hyphens, in which case a hyphen (-) will appear at the end of the line before the break.
58
-
59
-
The [raster mark](./README.md#raster) no longer crashes with an _identity_ color scale.
53
+
The [frame mark](./README.md#frame)’s new **anchor** option allows you to draw a line on one side of the frame (as opposed to the default behavior where a rect is drawn around all four sides); this feature is now used by the *scale*.**line** option for *x* and *y* scales. The [text mark](./README.md#text) now supports soft hyphens (`\xad`); lines are now eligible to break at soft hyphens, in which case a hyphen (-) will appear at the end of the line before the break. The [raster mark](./README.md#raster) no longer crashes with an _identity_ color scale. The [voronoi mark](./README.md#plotvoronoidata-options) now correctly respects the **target**, **mixBlendMode**, and **opacity** options.
Copy file name to clipboardExpand all lines: README.md
+63-27Lines changed: 63 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -966,64 +966,100 @@ Returns a new arrow with the given *data* and *options*.
966
966
967
967
### Auto
968
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:
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. For example,
// equivalent to Plot.dot(olympians, {x: "height", y: "weight"}).plot()
976
973
```
977
974
978
-
A monotonic quantitative dimension and another numeric one make a line chart:
975
+
makes a scatterplot (equivalent to [dot](#dot));
979
976
980
977
```js
981
978
Plot.auto(aapl, {x:"Date", y:"Close"}).plot()
982
-
// equivalent to Plot.lineY(aapl, {x: "Date", y: "Close"}).plot()
983
979
```
984
980
985
-
One quantitative dimension makes a histogram:
981
+
makes a line chart (equivalent to [lineY](#line); chosen because the selected *x* dimension *Date* is temporal and monotonic, _i.e._, the data is in chronological order);
986
982
987
983
```js
988
984
Plot.auto(penguins, {x:"body_mass_g"}).plot()
989
-
// equivalent to Plot.rectY(penguins, Plot.binX({y: "count"}, {x: "body_mass_g"})).plot()
990
985
```
991
986
992
-
One ordinal dimension makes a bar chart:
987
+
makes a histogram (equivalent to [rectY](#rect) and [binX](#bin); chosen because the _body_mass_g_ column is quantitative);
993
988
994
989
```js
995
990
Plot.auto(penguins, {x:"island"}).plot()
996
-
// equivalent to Plot.barY(penguins, Plot.groupX({y: "count"}, {x: "island"})).plot()
997
991
```
998
992
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.
993
+
makes a bar chart (equivalent to [barY](#bar) and [groupX](#group); chosen because the _island_ column is categorical).
994
+
995
+
Plot.auto seeks to provide a useful initial plot as quickly as possible through opinionated defaults, and to accelerate exploratory analysis by letting you see different dimensions of data with minimal code. For example, you can switch a vertical bar chart to a horizontal one by changing *x* to *y*; you don’t also have to switch barY to barX and groupX to groupY.
996
+
997
+
The auto mark supports a subset of the standard [mark options](#mark-options). You must provide at least one position channel:
998
+
999
+
* **x** - horizontal position
1000
+
* **y** - vertical position
1001
+
1002
+
You may also provide one or more visual encoding channels:
1003
+
1004
+
* **color** - corresponds to _stroke_ or _fill_ (depending on the chosen mark type)
1005
+
* **size** - corresponds to _r_ (and in future, possibly _length_)
1006
+
1007
+
And you may specify the standard mark-level facet channels:
1008
+
1009
+
* **fx** - horizontal facet position (column)
1010
+
* **fy** - vertical facet position (row)
1011
+
1012
+
In addition to channel values, the **x**, **y**, **color**, and **size** options may specify reducers. Setting a reducer on **x** implicitly groups or bins on **y**, and likewise setting a reducer on **y** implicitly groups or bins on **x**. Setting a reducer on **color** or **size** groups or bins in both **x** and **y**. Setting a reducer on both **x** and **y** throws an error. To specify a reducer, simply pass the reducer name to the corresponding option. For example:
To pass both a value and a reducer, or to disambiguate whether the given string represents a field name or a reducer name, the **x**, **y**, **color**, and **size** options can also be specified as an object with separate **value** and **reduce** properties. For example, to compute the total weight of the penguins in each bin:
Alternatively, you can specify a function of data or an array of values, as with a standard mark channel.
1000
1043
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
1044
+
The auto mark chooses the mark type automatically based on several simple heuristics. These heuristics are not explicitly documented and are likely to evolve over time; see the [source code](./src/marks/auto.js) for details. For more control, you can specify the desired mark type using the **mark** option, which supports the following names:
1009
1045
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
1046
+
* *area* - [areaY](#plotareaydata-options) or [areaX](#plotareaxdata-options) (or sometimes [area](#plotareadata-options))
1047
+
* *bar* - [barY](#plotbarydata-options) or [barX](#plotbarxdata-options); or [rectY](#plotrectydata-options), [rectX](#plotrectxdata-options), or [rect](#plotrectdata-options); or [cell](#plotcelldata-options)
1048
+
* *dot* - [dot](#plotdotdata-options)
1049
+
* *line* - [lineY](#plotlineydata-options) or [lineX](#plotlinexdata-options) (or sometimes [line](#plotlinedata-options))
1050
+
* *rule* - [ruleY](#plotruleydata-options) or [ruleX](#plotrulexdata-options)
1014
1051
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.
1052
+
The chosen mark type depends both on the options you provide (*e.g.*, whether you specified **x** or **y** or both) and the inferred type of the corresponding data values (whether the associated dimension of data is quantitative, categorical, monotonic, *etc.*). While the auto mark will respect the options you provide, you shouldn’t rely on its behavior being stable over time; to guarantee a specific chart type, specify the marks and transforms explicitly.
// equivalent to Plot.rect(athletes, Plot.bin({fill: "count"}, {x: "height", y: "weight"})).plot()
1059
+
Plot.auto(athletes, {x:"height", y:"weight", color:"count"}) // equivalent to rect + bin, say
1024
1060
```
1025
1061
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.
1062
+
Returns an automatically-chosen mark with the given *data* and *options*, suitable for a quick view of the data.
0 commit comments