Skip to content

Horizontal Parallel Coordinates ​

The parallel coordinates of the penguins with horizontal axes: cm.fold makes the measures categories of y, and with {x: {by: "y"}}, cm.plane gives each its own scale and axis along x.

js
const penguins = (await d3.csv("/data/penguins.csv", d3.autoType)).filter((d) => Number.isFinite(d.body_mass_g));
const measures = ["culmen_length_mm", "culmen_depth_mm", "flipper_length_mm", "body_mass_g"];

const renderer = cm.svg({width: 640, height: 400});
const root = cm.flow().renderer(renderer);

root
  .data(penguins)
  .transform(cm.encode, {stroke: "species"})
  .transform(cm.fold, {y: measures})
  .transform(cm.plane, {x: {by: "y"}, stroke: {legend: true}})
  .add(cm.lineX, {strokeOpacity: 0.3});

root.render();
document.body.append(renderer.node());