new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Observable Plot · all subjects

legends

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Legends for color, opacity, and symbol scales

Plot can generate legends for color, opacity, and symbol scales. Legends are not yet generated for radius (r) or length scales.

Legend types: swatches and ramp

For ordinal color scales with categorical schemes, a swatches legend is generated. For continuous color scales, a ramp legend with smooth gradient is generated. Ordinal color scales used redundantly with symbol scales incorporate the color encoding in the symbol legend for accessibility.

Legend scale option behavior

If the legend scale option is true, the default legend is produced. For quantitative color scales it defaults to ramp but may be set to swatches for discrete scales (most commonly for threshold color scales). For ordinal color scales and symbol scales, only swatches is supported. If the legend option is undefined, it is inherited from the top-level legend plot option.

Categorical and ordinal color legend options

Categorical and ordinal color legends (swatches) support: tickFormat (format function for labels), swatchSize (size if square), swatchWidth (width), swatchHeight (height), columns (number of swatches per row), marginLeft (left margin), className (defaults to randomly generated string), opacity (swatch fill opacity, v0.6.5+), width (in pixels).

Symbol legend options

Symbol legends are rendered as swatches and support all categorical/ordinal color legend options (tickFormat, swatchSize, swatchWidth, swatchHeight, columns, marginLeft, className, opacity, width) plus: fill (defaults to none), fillOpacity (defaults to 1), stroke (defaults to currentColor if fill is none, else none), strokeOpacity (defaults to 1), strokeWidth (defaults to 1.5), r (radius, defaults to 4.5 pixels). Fill and stroke can be specified as 'color' to apply the color scale when symbol scale is redundant encoding. Fill and stroke may be inherited from corresponding options on associated dot mark.

Continuous color legend (ramp) options

Continuous color legends rendered as ramp support: label (scale's label), ticks (desired number of ticks or array of tick values), tickFormat (format function for legend's ticks), tickSize (tick size), round (if true by default, round tick positions to pixels), width (legend's width), height (legend's height), marginTop, marginRight, marginBottom, marginLeft (all legend margins), opacity (ramp's fill opacity).

Legend style and className options

The style legend option allows custom styles to override Plot's defaults with same behavior as in Plot's top-level plot options. The className option is suffixed with either -ramp or -swatches, reflecting the legend type.

Plot.legend() function to render standalone legend

Plot.legend(options) renders a standalone legend for the scale defined by the given options object, returning a SVG or HTML figure element. The options object must define at least one scale and may include additional legend options. Example: Plot.legend({color: {type: 'linear'}}) renders a ramp legend of a linear color scale with default domain [0, 1] and default scheme turbo.

Symbol legend color encoding example

When an ordinal color scale is used redundantly with a symbol scale on the same data field, the symbol legend incorporates the color encoding. This improves accessibility for readers with color vision deficiency compared to using color alone.

Give your agent this brain