Scatterplot in the Terminal
A scatterplot of penguins drawn with the terminal renderer in pixel units, so that the vis layer lays it out as on any renderer: a cell is 6 by 12 pixels, the size of the 10px text the axes measure. Each penguin is a dot, a cell drawn as o in the color of its species, and the axes and the legend are characters.
js
const penguins = await d3.csv("/data/penguins.csv", d3.autoType);
const renderer = cm.terminal({width: 640, height: 400, units: "pixels"});
const root = cm.flow().renderer(renderer);
root
.data(penguins)
.transform(cm.encode, {x: "flipper_length_mm", y: "body_mass_g", stroke: "species"})
.transform(cm.plane, {y: {grid: true}, stroke: {legend: true}})
.add(cm.circle, {r: 3});
root.render();
document.body.append(renderer.node());