Making Lexis maps in Tableau
Lexis maps (also “Lexis diagrams”) are used mainly by demographers to show population trends over time. (I’ll explain below how to adapt them for other kinds of data.) They combine elements of scatterplots (quantitative values and individual data points) with the benefits of a heatmap (intensity coloring of some trend). Demographers like them because they drill down on aggregate population trends (e.g. birth rate, death rate, morbidity rates) to show how events affect different segments of the population at different ages. This one shows the baby boom of the 1950s and 60s through female birth rates from ages 14–49.
Though few have heard of them outside of demography, Lexis maps can handle the complex type of data that visualization was meant for: quantitative, longitudinal, high-density, multivariate data. Most Lexis diagrams span a hundred years or more for ages 0–100+, resulting in tens of thousands of data points in a single display. As others have put it
Lexis maps might be compared to a lavish Chinese banquet, whereas the graphs over age and time are more like a delicate Japanese dinner (Vaupel, et al 1998).
Given all this, Lexis maps have great potential, and I’m hopeful we’ll see them used in interesting ways beyond demography (I’m still a big fan of demography). To help that along, I put together this workflow for creating Lexis maps in Tableau Public, a free version of the software used by places like the New York Times and Gallup. Tableau Public publishes web-based interactive displays that are sharable and embeddable in HTML—and it has a great video tutorials.
If you want to skip straight to the Tableau instructions, click here.
Lexis maps are often attributed to Wilhelm Lexis’s 1875 proposal for diagramming population trends by birth cohort (though apparently they were proposed earlier). The basic idea is to model each person as a line beginning with their birth and ending at the age of their death. Putting all of these together at yearly intervals, you get birth cohorts for the population, which move together through time and are affected similarly as they move through time—more similarly even than other people who live through the same event, but experience it at different ages. Even a massive historical event such as World War II affects people differently; some are drafted, but others are too old or too young, and the event affects them in other ways. The same might be true of pregnancy or some disease. Model all of this on two axes (time x age) and you have a Lexis diagram.
This Lexis map shows the probabilities of death for Italian males, with historical events (e.g., WWI, WWII) clearly reflected in the population patterns.
Lexis maps can also be adapted to a variety of domains beyond demography. For example, I’ve used them to study gender ratios in publication rates of academic philosophers (treating PhD date as “birth” or entry into the field).
The visualizations above were created with Kirill Andreev’s Lexis Map Viewer, which was last updated in 1997 and requires Windows 3.1 or higher. Though the software is still great at what it does, it’s relatively obscure in the wider visualization world and outputs only static images.
After playing around in Tableau a bit, I realized that I could create Lexis maps using a symbol display, with the added benefits of interactivity, filtering, and more color options. Here’s a Tableau Lexis map of Italian mortality rates for the same period as the first graph above, with some annotations highlighting trends. You can also hover over individual data points to get exact probabilities for any cohort in a specific year. (The original graph uses cohort data from Natale and Bernassola (1973) and Caselli et al. (1985). My dataset comes from the Human Moratality Database, so there may be slight differences in the data.)
Below, I’ve outlined the key steps for making Lexis maps in Tableau Public, in hopes that demographers and others will be able to make use of this free tool.
As with other datasets, Tableau requires normalized (not crosstab) data. There’s a great post on how to shape your data for Tableau, but most demographic data comes readily formatted.
To make a Lexis map in Tableau, set up your worksheet as follows:
- Rows: Your variable for age. Again, this does not have to be natural age; some other examples might be grade level, or time from graduation. Be sure to set the options to Dimension (not sum) and Continuous.
- Detail: The variable of interest—in my case, probability of death, q(x).
- Marks and Size: Set the visualization type to Square and adjust the size so that each data point is just large enough that there is no white space between them (the smallest auto size usually works).
- Filters: If you want to allow people to filter by year or age, add those variable to Filters and set them as Quick Filters. I put those below my graph so they are present but not distracting.
- Color: The trickiest part. I realized that Lexis Map Viewer doesn’t use a linear scale for color, probably to highlight changes in trends more clearly. To replicate this effect, I created a calculated field on my variable of interest (right click on the variable) and computed the log of my variable, q(x). I used this new calculated field for Color, and chose a temperature diverging scale with 18 steps (the same number used in the original graph). If you want a smoother display, use more steps or turn off stepped color.
- Tooltip: Finally, set up your Tooltip to display the information you want on hover. Since we use the calculated field and not the actual variable, I added that to Detail first (as Attribute), then I customized the Tooltip by removing the calculated field and adding my variable, q(x).
Overall, your Tableau worksheet should look something like this
And in case you were wondering, here’s what Italian female mortality looks like:
Andreev, Kiril. Lexis Map Viewer, Version 1.0. [Computer program.] http://www.demogr.mpg.de/books/odense/9/cd/default.htm.
Lexis, Wilhelm. 1875. Einleitung in die Theorie der Bevölkerungsstatistik. Karl Trübner, Straßburg. OCLC 27127671.
Vandeschrick, Christophe (2001). The Lexis diagram, a misnomer. Demographic Research, 4(3):97-124. URL http://www.demographic-research.org/Volumes/Vol4/3/4-3.pdf.
Vaupel, James W., Wang Zhenglian, Kirill F. Andreev, and Anatoli I. Yashin (1998). Population Data at a Glance: Shaded Contour Maps of Demographic Surfaces over Age and Time. Odense Monographs on Population Aging, 4. Odense University Press. http://www.demogr.mpg.de/Papers/Books/Monograph4/start.htm.
One Response to Making Lexis maps in Tableau
Trackbacks & Pingbacks
[…] Materials Through the census site, I downloaded a .csv which provided over 470,000 cells to work with. It was workable overall and just needed one column to be transposed. I kept the project data from 2010 through 2050 as well as the county code numbers (FIPS) with the thought that I can either filter them out or utilize them when cross comparing in Tableau. When inputting age, I grouped them in “bins” of 10 to make them more manageable in a visualization. For my dashboard, I included three charts. One line chart takes the four largest counties in California and the other line chart takes the four smallest counties, both compare county population over time by the following age groups: 20, 30 and 60. With 49 counties, it I selected the four smallest and largest counties as a way to make the data more manageable. The third visualization is a Lexis map, that gives the viewer the ability to select any and as many California counties as they would like to compare. In creating the Lexis map, I referenced Tableau’s help board and Professor Sula’s guide. […]
Leave a ReplyWant to join the discussion?
Feel free to contribute!