We have one of those TVs in the elevators at work that flashes headlines. While these have kept me a bit more informed about current events, they’ve been detrimental to elevator conversations.
So I’m riding the elevator the other day, talking to no one, and a headline appears about the incredible decline in teen pregnancy rate. I thought this would be a perfect opportunity to “show” the results in Tableau.
The trend data comes from the Guttmacher Institute and the state-level data come from The National Campaign to Prevent Teen and Unplanned Pregnancy. Additional context comes from the CDC.
I used a couple of techniques in Tableau that I will explain after the viz. But first, some notes from explaining the situation.
- Despite legalized aborting in 1973, the significant increases in pregnancy rates in the the 1980s and early 1990s are explained by increased birthrates but stable abortion rates.(Guttmacher)
- Almost all of the decline in the pregnancy rate between 1995 and 2002 among 18–19-year-olds was attributable to increased contraceptive use. (Guttmacher)
- Among women aged 15–17, about one-quarter of the decline during the same period was attributable to reduced sexual activity and three-quarters to increased contraceptive use. (Guttmacher)
- The teen birth rate in the United States declined during 1991--2009 to its lowest level in the nearly 70 years. (CDC)
When looking at pregnancy rates what stuck out to me immediately is the clear dividing line between the north and the south. According to the CDC, teen birth rates in the United States have declined but remain high, especially among black and Hispanic teens and in southern states. Perhaps the higher rates are explained by race, but I wonder if the rates can be partly explained by the religious stigmas that are associated with abortion in the south. Or perhaps sex education programs are not as strongly emphasized. I haven’t found data to support my theories, but having lived here for almost 15 years, I notice what’s going on around me.
This blog post from Matt Stiles made me think not only the number of pregnancies, but also the rate. The rate gives you a much more accurate comparison across states.
You might notice that I have three maps, one for the continental US and then one for each of Alaska and Hawaii. This is done so that the map isn’t so zoomed out when looking at all of the states in one map. Tableau does not come with a map like this so I:
- Created a single map of all states,
- Zoomed in on the continent,
- Pinned the map, and
- Hid the zoom controls.
- Duplicated the map twice,
- Changed the zoom to Alaska and Hawaii respectively, and
- Placed all three maps on a dashboard.
The reason I duplicated the maps instead of filtering each of the maps is because the color scale would not be accurately represented on any of the maps. I want all states to use the same scale, therefore all states are actually on all of the maps.
I added a subtle feature you may not notice. As you change the statistic from the drop down on the upper left, the title for the color legend changes dynamically. Tableau doesn’t allow you to expose information from the viz in titles for the Size and Color cards like it does for captions, titles, tooltips, etc. Here’s the technique I used to work around this limitation:
1. Create a calculated field for a label based on the statistic selected (which is a parameter)
2. Create a blank worksheet and place this calculated field on the Level of Detail shelf
3. Updated the title of the worksheet to expose this field
4. Format the worksheet so that the rows and columns are as small as possible and the gridlines are removed
5. Place the worksheet on the dashboard above the color legend
6. Change the Fit to Entire View
7. Show the title
That’s it. I now have a dynamic title for the color legend.