Comments (3)
I've now implemented this through various test notebooks that are not yet fully ready (coming soon). I'm enthusiastic about the idea of selecting the bandwidth relative to the variance of each dimension, but there are already a few observations I can share:
First, there is an obvious case where it doesn't work: when the data has no variance (maybe it's a single point, or points that show very small variation in y, for some reason). In those cases we wouldn't want the density contours to be flattened to a line. So there's going to be a sort of minimum, which can be set at the (arbitrary) default value of 20 pixels that exists already.
Second, the way it looks is a bit underwhelming. The current strategy creates "circles" around the data, the x/y aspect ratio creates "ellipses" (on purpose). Certainly nicer for statistics, but not as nice on the eye. So, I would not want to have a different aspect ratio with the default bandwidth generator.
Third, the nrd formula returns values that don't coincide with the way we use the given bandwidth. (Currently bandwidth represents, let's say, the radius of 1 iteration of blurring on a 4x grid, whereas in the litterature it's something like the std dev of the gaussian.) In my experiments, the scale factor between these values is about 5.
As a consequence, either we change, and users will have to rescale their hand-tuned bandwidths (my experience with this is that it's always hand-tuned to give a "nice" graph), or we continue with the same "bandwidth" and scale nrd to match what it's supposed to deliver, but its statistical properties are incorrect. Maybe a solution could be to deprecate bandwidth() and replace it with a new name like blur() or something.
from d3-contour.
Here's an implementation that seems to work, based on the new d3.blur proposal.
https://observablehq.com/@fil/x-y-bandwidth-for-density-contours
The remarks above still stand.
from d3-contour.
I figure that as a first step we should ship a version that accepts x/y bandwidths as inputs, and allow experimentations (this depends in turn on d3.blur (d3/d3-array#151).
For the nrd stuff, I'd wait for serious statisticians to test and validate the approach.
from d3-contour.
Related Issues (20)
- Release d3-array v2 compatible version? HOT 2
- hole issue in contour HOT 5
- Arrows using elevation value for any point(x, y) in contour chart HOT 5
- GeoJSON Geometry which is generated by d3.contour displays wrong HOT 3
- output data has index which is not exist in input data HOT 2
- Feature request: contour labels HOT 2
- smoothing removes line segements HOT 1
- Buggy input check in density size setter.
- Improve slow computations for large images HOT 2
- Handle Null values in grid HOT 9
- Dependencies HOT 3
- Some contour polygon is reverse. HOT 5
- Support fractional bandwidths. HOT 2
- [feature]: cellSize(0.5) would work well in d3.contourDensity() HOT 1
- Support curvilinear grids HOT 11
- Sometimes the lowest threshold is missing
- Bug HOT 2
- Breaking change with contour-density thresholds starting from v3.0.2 HOT 2
- isobands?
- Donβt round the corners HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-contour.