# Word frequency

> Use word frequency bars to show the most used words in a text, sorted, once the common little words are removed.

- Data type: Words and text (`text`)
- Free (MIT): install with `npx chartreuse add word-frequency`, or registry item `/r/word-frequency.json`
- Example: **In Frankenstein, “father” comes up four times as often as “monster”** (The 20 most used words in Mary Shelley's Frankenstein (1818 text), and the names Victor gives his creation, counts)
- How to read it: Each bar counts one word across the whole novel; the right-hand bars use the same scale for the creature's names.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9, 9:16 (best 9:16)

## Use it when
- a first look at what a text is about
- comparing a handful of chosen words on one scale
- up to about 30 words

## Avoid it when
- comparing texts of different lengths (use rates per 10,000 words)
- meaning depends on context (use a word tree or keyword in context)
- word clouds are tempting: sorted bars are easier to read

## Fields (data.json)
- `totalWords` (number, unit "words", format count): words in the text
- `rows[].word` (text): a word, lower case
- `rows[].count` (number, unit "times", format count): times it appears
- `names[].word` (text): optional: a second list of chosen words, drawn on the same scale (its heading is the hint namesHead)
- `names[].count` (number, unit "times", format count): times it appears

Units are the example's: with your own data, set each number field's `unit` and `format` (percent, count, decimal, currency, compact) in the meta you pass to mount, or `chartreuse render --unit field=text --format field=count`. Scales and labels follow your data.

## Interactions, motion, sound
- hover or tap a bar for its count and rate per 10,000 words
- Motion: Bars grow from zero in rank order, then the creature's names follow.
- Sound: A soft pop on hover; Play speaks each word. Quiet while it draws and between steps; mute it from its card. (sound is off until the viewer turns it on)

## Example spec
```json
{
  "chart": "word-frequency",
  "title": "In Frankenstein, “father” comes up four times as often as “monster”",
  "subtitle": "The 20 most used words in Mary Shelley's Frankenstein (1818 text), and the names Victor gives his creation, counts",
  "data": "/charts/word-frequency.data.json"
}
```

## Source
Frankenstein; or, the Modern Prometheus by Mary Wollstonecraft Shelley (eBook #84), Project Gutenberg (Public domain in the USA (Project Gutenberg License)), retrieved 2026-12-01: https://www.gutenberg.org/ebooks/84

Note: Counted from the plain-text edition, letters and chapters only; possessive 's is folded into the word. About 150 common function words (the, upon, can, thou…) are left out.

Live: /charts/word-frequency · Manifest: /charts/word-frequency.json · Tags: text, words, frequency, books, literature, Frankenstein, sorted bars
