Alabama First
Showing and telling
Advice
Introductory
Howard Wainer’s term for the common error of plotting in alphabetical order rather than based on some more informative variable.
What it is
Howard Wainer’s name for the habit of ordering categories alphabetically in a table or chart: Alabama, Alaska, Arizona and so on. Alphabetical order is convenient for looking up a single value. It is almost never the best order for seeing a pattern. Order by the value being plotted, or by a meaningful grouping such as region or time, and the structure in the data appears.
Why it matters
Most statistical graphs exist so readers can make comparisons. Alphabetical order scatters similar values across the page and hides gradients, clusters and outliers. It is the default in most software, which is why it is so common. Changing the sort order costs nothing and often turns a meaningless list into an informative display.
How it works
Sort the categorical axis by:
- The plotted value, to see the ranking and the gaps.
- A meaningful grouping (region, party, era), to reveal whether groups differ.
- A related covariate, to show a relationship without a scatterplot.
If readers need to look items up, add labels or a searchable table alongside. Don’t make the graph do a lookup table’s job.
Simulated example
Fifty states with a simulated outcome that depends on region plus noise. Switch the sort order and see how much easier the regional pattern is to spot.
Show simulation code
The R version uses base R, and the Python version uses NumPy and Matplotlib. Where the simulation draws random numbers, each language draws its own, so exact numbers differ slightly but show the same pattern. The numbered markers in the R code are explained under it.
import {rng, fmt} from "../js/stats.js"
viewof order = Inputs.radio(["Alphabetical", "By value", "By region, then value"], {value: "Alphabetical", label: "Sort order"})
viewof regionGap = Inputs.range([0, 10], {value: 6, step: 0.5, label: "Size of regional differences"})
viewof seed = Inputs.range([1, 500], {value: 14, step: 1, label: "Random seed"})
statesRegions = [["Alabama","South"],["Alaska","West"],["Arizona","West"],["Arkansas","South"],["California","West"],["Colorado","West"],["Connecticut","Northeast"],["Delaware","South"],["Florida","South"],["Georgia","South"],["Hawaii","West"],["Idaho","West"],["Illinois","Midwest"],["Indiana","Midwest"],["Iowa","Midwest"],["Kansas","Midwest"],["Kentucky","South"],["Louisiana","South"],["Maine","Northeast"],["Maryland","South"],["Massachusetts","Northeast"],["Michigan","Midwest"],["Minnesota","Midwest"],["Mississippi","South"],["Missouri","Midwest"],["Montana","West"],["Nebraska","Midwest"],["Nevada","West"],["New Hampshire","Northeast"],["New Jersey","Northeast"],["New Mexico","West"],["New York","Northeast"],["North Carolina","South"],["North Dakota","Midwest"],["Ohio","Midwest"],["Oklahoma","South"],["Oregon","West"],["Pennsylvania","Northeast"],["Rhode Island","Northeast"],["South Carolina","South"],["South Dakota","Midwest"],["Tennessee","South"],["Texas","South"],["Utah","West"],["Vermont","Northeast"],["Virginia","South"],["Washington","West"],["West Virginia","South"],["Wisconsin","Midwest"],["Wyoming","West"]]
stateData = {
const r = rng(seed);
const eff = {Northeast: 1, Midwest: 0, South: -1, West: 0.4};
return statesRegions.map(([state, region]) => ({state, region, value: 50 + regionGap * eff[region] + r.normal(0, 3)}));
}
sorted = {
const d = stateData.slice();
if (order === "By value") d.sort((a, b) => b.value - a.value);
else if (order === "By region, then value") d.sort((a, b) => a.region.localeCompare(b.region) || b.value - a.value);
return d;
}
Plot.plot({
ariaLabel: "Alabama First: simulation chart",
ariaDescription: "Horizontal axis: Simulated outcome. The chart updates with the controls above it, and the summary below the charts states the result in words.",
height: 760,
marginLeft: 110,
x: {label: "Simulated outcome", grid: true},
y: {label: null, domain: sorted.map(d => d.state)},
color: {legend: true, range: ["#2166ac", "#d6604d", "#1a9850", "#984ea3"]},
marks: [
Plot.ruleY(sorted, {y: "state", x1: 30, x2: "value", stroke: "#ddd"}),
Plot.dot(sorted, {y: "state", x: "value", fill: "region", r: 4})
]
})# Alabama First: the same 50 states sorted three ways.
1order_by <- "alphabetical" # "alphabetical", "value" or "region"
region_gap <- 6 # size of regional differences
2set.seed(14)
region <- as.character(state.region) # R's built-in census regions
region[region == "North Central"] <- "Midwest"
effect <- c(Northeast = 1, Midwest = 0, South = -1, West = 0.4)
3value <- 50 + region_gap * effect[region] + rnorm(50, 0, 3)
states <- data.frame(state = state.name, region, value)
4states <- switch(order_by,
alphabetical = states,
value = states[order(-states$value), ],
region = states[order(states$region, -states$value), ]
)
cols <- c(
Midwest = "#2166ac", Northeast = "#d6604d", South = "#1a9850",
West = "#984ea3"
)
5dotchart(rev(states$value),
labels = rev(states$state), pch = 19,
col = cols[rev(states$region)], cex = 0.6,
xlab = "Simulated outcome"
)
legend("bottomright", names(cols), col = cols, pch = 19, cex = 0.7)
cat("Regional gap (Northeast minus South):", 2 * region_gap, "points\n")- 1
- The page’s controls: how to order the states, and how large the regional differences are.
- 2
- Fixes the random numbers so the run is reproducible.
- 3
- A made-up outcome with a regional pattern plus noise. R’s built-in census regions supply the structure.
- 4
- The same 50 values, ordered alphabetically (Alabama first), by value, or by region and then value.
- 5
- The dot chart. Alphabetical order hides the regional pattern that the other two orders make obvious.
# Alabama First: the same 50 states sorted three ways.
import numpy as np
import matplotlib.pyplot as plt
order_by = "alphabetical" # "alphabetical", "value" or "region"
region_gap = 6 # size of regional differences
rng = np.random.default_rng(14)
regions = {
"Northeast": "Connecticut Maine Massachusetts New_Hampshire New_Jersey "
"New_York Pennsylvania Rhode_Island Vermont",
"Midwest": "Illinois Indiana Iowa Kansas Michigan Minnesota Missouri "
"Nebraska North_Dakota Ohio South_Dakota Wisconsin",
"South": "Alabama Arkansas Delaware Florida Georgia Kentucky Louisiana "
"Maryland Mississippi North_Carolina Oklahoma South_Carolina "
"Tennessee Texas Virginia West_Virginia",
"West": "Alaska Arizona California Colorado Hawaii Idaho Montana Nevada "
"New_Mexico Oregon Utah Washington Wyoming",
}
effect = {"Northeast": 1, "Midwest": 0, "South": -1, "West": 0.4}
states = sorted((s.replace("_", " "), r) for r, names in regions.items()
for s in names.split())
rows = [(s, r, 50 + region_gap * effect[r] + rng.normal(0, 3))
for s, r in states]
if order_by == "value":
rows.sort(key=lambda d: -d[2])
elif order_by == "region":
rows.sort(key=lambda d: (d[1], -d[2]))
colors = {"Midwest": "#2166ac", "Northeast": "#d6604d", "South": "#1a9850",
"West": "#984ea3"}
y = np.arange(len(rows))[::-1]
plt.figure(figsize=(6, 10))
plt.scatter([d[2] for d in rows], y, c=[colors[d[1]] for d in rows])
plt.yticks(y, [d[0] for d in rows], fontsize=7)
plt.xlabel("Simulated outcome")
plt.tight_layout()
plt.show()
print(f"Regional gap (Northeast minus South): {2 * region_gap} points")Key takeaways
- Alphabetical order is for lookup, not for comparison.
- Sort by the quantity of interest or by a meaningful grouping.
- Software defaults are not design decisions. Change them on purpose.
Source
- Andrew Gelman, Unalphabetize! (2008).
- Howard Wainer, Graphic Discovery (2005).