# Letter frequency

> Use a letter-frequency chart to show how often each letter appears in a text, usually against a reference text so the differences stand out.

- Data type: Words and text (`text`)
- Free (MIT): install with `npx chartreuse add letter-frequency`, or registry item `/r/letter-frequency.json`
- Example: **Gadsby's 51,810 words use the letter e four times, all of them printing slips** (Share of all letters, a to z, in Gadsby (1939) and Pride and Prejudice (1813))
- How to read it: Each pair of bars is one letter: its share of every letter in each novel; Gadsby was written to avoid e altogether.
- Interactive: sort
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: none passed; closest 9:16

## Use it when
- comparing the make-up of a text with a reference (ciphers, constrained writing, languages)
- there are up to about 30 symbols
- the shape of the whole alphabet matters

## Avoid it when
- you care about words, not letters (use word frequency)
- there is no reference to compare with and the order means nothing
- more than 4 texts (only the first ones and the reference are drawn; the key says how many are left out)
- more than about 30 symbols (past 32 the least common fold into one "…" bar)
- the text is very short (shares are noisy)

## Fields (data.json)
- `books[].title` (category): the text: 1 to 4 of them, side by side; the last is the reference (or the one titled hints.reference), and with one there is no comparison
- `books[].counts` (number, unit "letters", format count): times each letter or symbol appears; its keys, in order, are the alphabet (a to z here, accents removed, case ignored)
- `books[].letters` (number, unit "letters", format count): all letters counted
- `books[].words` (number, unit "words", format count): words counted

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 to read the share and count
- sort in alphabet order or by how common each letter is in the reference text
- Motion: The bars grow letter by letter; then one letter is called out (hints.letter if set, else the one that differs most from the reference: e in the example).
- Sound: A whoosh on re-sort. 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": "letter-frequency",
  "title": "Gadsby's 51,810 words use the letter e four times, all of them printing slips",
  "subtitle": "Share of all letters, a to z, in Gadsby (1939) and Pride and Prejudice (1813)",
  "data": "/charts/letter-frequency.data.json"
}
```

## Source
Gadsby by Ernest Vincent Wright (eBook #47342); Pride and Prejudice by Jane Austen (eBook #1342), Project Gutenberg (Public domain), retrieved 2026-12-01: https://www.gutenberg.org/ebooks/47342

Note: Gadsby is counted from the first line of its story to "FINIS", leaving out the introduction, which uses e freely. The transcriber notes that three "the"s and one "officers" slipped into the printed book; those are the four e's.

Live: /charts/letter-frequency · Manifest: /charts/letter-frequency.json · Tags: letters, alphabet, text, frequency, lipogram, constrained writing, literature, cryptography
