Published
Edited
Apr 26, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
vega({
height: 500,
width: 500,
title: "Fitness changes",
layer: data.map(({ theta, label, color }) => vegaRadialLine(theta, { label, color }))
})
Insert cell
gamma = {
const sum_a = d3.sum(alphas);
const sum_a2 = d3.sum(alphas.map(a => a * a))
const sum_ab = d3.sum(alphas.map(a => a * (1 - a)))
return N * (sum_ab - sum_a2) / sum_a
}
Insert cell
data = {
const data = slopes.map((d, i) => ({
theta: Math.atan(d.value),
label: d.label,
color: d3.schemeCategory10[i],
}))
return data
}
Insert cell
slopes = [
{ value: 1, label: "individual - other-only" },
{ value: Infinity, label: "individual - whole-group" },
{ value: -1 / (N * alpha - 1), label: "group - other-only" },
{ value: -1 / (N * alpha), label: "group - whole-group" },
{ value: 1 / (gamma + 1), label: "multilevel - other-only" },
{ value: 1 / gamma, label: "multilevel - whole-group" },
]
Insert cell
alphas = d3.range(N).map(i => getAlpha_i())
Insert cell
function vegaRadialLine(theta, {
height = 200,
width = 300,
color = "red",
label = "",
} = {}) {
return {
title: label,
data: { values: [ { theta: PI/2 - theta, theta2: (PI/2 - theta) + 0.05, color, label, r: 1, r2: -1 } ] },
height,
width,
mark: {
type: "arc",
// stroke: color,
filled: true,
color,
},
encoding: {
radius: { field: "r", type: "quantitative", title: "Radius", "scale": {"domain": [0, 1]} },
radius2: { field: "r2", type: "quantitative", title: "Radius", "scale": {"domain": [0, 1]} },
theta: { field: "theta", type: "quantitative", title: "Theta", "scale": {"domain": [0, 2*PI]} },
theta2: { field: "theta2", type: "quantitative" },
// color: { field: "label", type: "nominal", range: ["green", "purple"],
// legend: { symbolType: "circle", symbolStrokeColor: color, symbolStrokeWidth: 4 } },
color: { field: "label" }
}
}
}
Insert cell
Insert cell
Insert cell
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