Skip to main content
100%

print_template - colour scale

✓ Published0🌍 Public
RRobinL
Last edited Jul 24, 2016
Created on Jun 28, 2016

This example demonstrates the non-linear nature of d3’s linear color scale by mapping a custom domain [0, 0.25, 0.5, 0.75, 1] to a range of five distinct colors, from white through green, yellow, and red to black. The code prints the color values for a set of input numbers, then normalizes logarithmic values from 0.001 to 1 and prints those colors as well, revealing how the scale compresses and expands color transitions unevenly. Using d3.scale.linear, d3.format, and d3.range, the visualization appends text labels to an SVG canvas via d3.select and svg.selectAll, with the author’s custom print() function collecting outputs for display.

AI-generated description

Similar vizzes