{
const nonRepeatedData = data.filter(d => d.i < d.j);
const referenceLines = [
{ x: 0.46, label: "Intimate Distance", dx: -0.1 },
{ x: 1.2, label: "Personal Distance", dx: -0.2 },
{ x: 3.6, label: "Social Distance", dx: -0.4 },
{ x: 7.6, label: "Public Distance (close)", dx: -0.8 },
{ x: 7.7, label: "Public Distance (far)", dx: +0.9 }
];
return Plot.plot({
grid: "true",
x: {
nice: true,
type: "pow",
ticks: 10,
exponent: 0.5,
label: "Distance in meters"
},
y: {
nice: true,
percent: true
},
width: 900,
facet: {
data: nonRepeatedData,
y: "technology",
x: "audio",
label: null,
marginRight: 80
},
marks: [
Plot.frame({ stroke: "#aaa" }),
Plot.tickX(referenceLines, {
x: "x",
stroke: "#222"
}),
Plot.text(referenceLines, {
x: d => d.x + d.dx,
text: "label",
rotate: -90,
textAnchor: "start",
dx: -14,
fill: "#999"
}),
Plot.lineY(
nonRepeatedData,
Plot.normalizeY({
basis: "sum",
...Plot.binX(
{
y: "count"
},
{
x: "distance",
stroke: "subGroup"
}
)
})
)
]
});
}