Skip to content

Commit aaba03b

Browse files
committed
explicit "auto" thresholds
1 parent b7282a3 commit aaba03b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ Plot.binX({y: "count"}, {x: {thresholds: 20, value: "culmen_length_mm"}})
10391039

10401040
The **thresholds** option may be specified as a named method or a variety of other ways:
10411041

1042+
* *auto* (default) - Scott’s rule, capped at 200.
10421043
* *freedman-diaconis* - the [Freedman–Diaconis rule](https://en.wikipedia.org/wiki/Freedman–Diaconis_rule)
10431044
* *scott* - [Scott’s normal reference rule](https://en.wikipedia.org/wiki/Histogram#Scott.27s_normal_reference_rule)
10441045
* *sturges* - [Sturges’ formula](https://en.wikipedia.org/wiki/Histogram#Sturges.27_formula)
@@ -1047,7 +1048,7 @@ The **thresholds** option may be specified as a named method or a variety of oth
10471048
* a time interval (for temporal binning)
10481049
* a function that returns an array, count, or time interval
10491050

1050-
If the **thresholds** option is not specified, it defaults to *scott*, capped at 200. If a function, it is passed three arguments: the array of input values, the domain minimum, and the domain maximum. If a number, [d3.ticks](https://github.com/d3/d3-array/blob/master/README.md#ticks) or [d3.utcTicks](https://github.com/d3/d3-time/blob/master/README.md#ticks) is used to choose suitable nice thresholds.
1051+
If the **thresholds** option is specified as a function, it is passed three arguments: the array of input values, the domain minimum, and the domain maximum. If a number, [d3.ticks](https://github.com/d3/d3-array/blob/master/README.md#ticks) or [d3.utcTicks](https://github.com/d3/d3-time/blob/master/README.md#ticks) is used to choose suitable nice thresholds.
10511052

10521053
The bin transform supports grouping in addition to binning: you can subdivide bins by up to two additional ordinal or categorical dimensions (not including faceting). If any of **z**, **fill**, or **stroke** is a channel, the first of these channels will be used to subdivide bins. Similarly, Plot.binX will group on **y** if **y** is not an output channel, and Plot.binY will group on **x** if **x** is not an output channel. For example, for a stacked histogram:
10531054

src/transforms/bin.js

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ function maybeThresholds(thresholds = thresholdDefault) {
177177
case "freedman-diaconis": return thresholdFreedmanDiaconis;
178178
case "scott": return thresholdScott;
179179
case "sturges": return thresholdSturges;
180+
case "auto": return thresholdDefault;
180181
}
181182
throw new Error("invalid thresholds");
182183
}

0 commit comments

Comments
 (0)