Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d3.scaleQuantileP #93

Closed
mbostock opened this issue Dec 19, 2016 · 2 comments
Closed

d3.scaleQuantileP #93

mbostock opened this issue Dec 19, 2016 · 2 comments
Assignees

Comments

@mbostock
Copy link
Member

mbostock commented Dec 19, 2016

How about in addition to d3.scaleQuantile, which requires you to specify a range with q elements to compute q-quantiles, you also have d3.scaleQuantileP, whose range is continuous and defaults to [0, 1], computing the p-quantile of an input value from the domain.

And then you can specify an output interpolator, say d3.interpolateViridis, so that you can map the p-quantile of the input value to a color.

Though this is somewhat tricky because it’s not clear whether d3.scaleQuantileP should function more like a d3.scaleSequential that takes a fixed output interpolator, or d3.scaleLinear where you can specify both the range and the interpolator.

@mbostock mbostock self-assigned this Dec 19, 2016
@mbostock
Copy link
Member Author

This is closely related to #62 as implemented in @393b9a5: d3.scaleSequentialQuantile computes the p-quantile prior to applying the interpolator.

@mbostock mbostock mentioned this issue Jan 25, 2019
Merged
13 tasks
@mbostock
Copy link
Member Author

mbostock commented Jan 25, 2019

As previously commented, I think d3.scaleSequentialQuantile covers this need.

If you want discrete quantiles, use d3.scaleQuantile:

color = d3.scaleQuantile().domain(values).range(d3.schemeBlues[9])

If you want continuous quantiles, use d3.scaleSequentialQuantile:

color = d3.scaleSequentialQuantile(d3.interpolateBlues).domain(values)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant