Published
Edited
Mar 1, 2022
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
y = d3
.scaleLinear()
.domain([0, d3.max(waveIntervals)])
.range([height - margin.bottom, margin.top])
.nice()
Insert cell
yAxis = g =>
g
.attr('transform', `translate(${margin.left}, 0)`)
.call(d3.axisLeft(y).ticks(20))
.call(g => g.select(".domain").remove())
.call(g =>
g
.append("text")
.attr("x", -margin.left)
.attr("y", 10)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.text("↑ Time between waves (s)")
)
Insert cell
x = d3
.scaleLinear()
.domain([-1, waveIntervals.length])
.range([margin.left + kernelWidth, width - margin.right])
Insert cell
xAxis = g =>
g
.attr('transform', `translate(0, ${height - margin.bottom})`)
.call(d3.axisBottom(x).ticks(20))
.call(g => g.select(".domain").remove())
.call(g =>
g
.append("text")
.attr("x", width)
.attr("y", margin.bottom - 25)
.attr("fill", "currentColor")
.attr("text-anchor", "end")
.text("Order of waves →")
)
Insert cell
x2 = d3
.scaleLinear()
.domain([0, d3.max(waveIntervalPairs, p => p[1])])
.range([margin.left, width - margin.right])
.nice()
Insert cell
xAxis2 = g =>
g
.attr('transform', `translate(0, ${height - margin.bottom})`)
.call(d3.axisBottom(x2).ticks(20))
.call(g => g.select(".domain").remove())
.call(g =>
g
.append("text")
.attr("x", width)
.attr("y", margin.bottom - 25)
.attr("fill", "currentColor")
.attr("text-anchor", "end")
.text("Previous time between waves (s) →")
)
Insert cell
contours = d3
.contourDensity()
.x(d => x2(d[1]))
.y(d => y(d[0]))
.size([width, height])
.bandwidth(30)
.thresholds(30)(waveIntervalPairs)
Insert cell
line = d3
.line()
.curve(d3.curveBasis)
.x(d => xDensity(d[1]))
.y(d => y(d[0]))
Insert cell
xDensity = d3
.scaleLinear()
.domain([0, d3.max(densities, d => d[1])])
.range([kernelWidth, 5])
Insert cell
densities = kde(epanechnikov(1.1), y.ticks(100), waveIntervals)
Insert cell
kernelWidth = 80
Insert cell
margin = ({ top: 20, bottom: 20, left: 30, right: 20 })
Insert cell
height = 500
Insert cell
waveIntervalPairs = waveIntervals
.map((w, i) => (i == 0 ? null : [w, waveIntervals[i - 1]]))
.filter(d => d)
Insert cell
Insert cell
d3 = require('d3')
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more