June 28, 2021
#MakeoverMonday Week 26 - How Popular Is Your Birthday?
January 18, 2017
Workout Wednesday: The State of U.S. Jobs
Last week on my Data Viz Done Right site, I wrote about a great small multiples visualisation created by Matt Stiles that shows U.S. unemployment compared to the national average for every State. I recreated Matt’s work in Tableau, and your challenge for this week is to do the same. Personally, I find trying to rebuild visualisations a great way to learn.
Below you’ll see an image of what I created. Click on it for the interactive version. I’ve prepared the data for you here (it comes from the Bureau of Labor Statistics). Some things to keep in mind:
- My viz is 875x2150. Your’s doesn’t have to be this size, but I thought I’d provide it for guidance.
- I’m using the Source Sans Pro font, which you can download from Google Fonts. This is the font that Matt used in his version.
- The years should be displayed every 10 years.
- The axis line on for the year should be more distinct than the gridlines.
- The ends of each line should be colour-coded by whether it was an increase or decrease compared to the national average.
- You will need to calculate the national average. The national average needs to include the District of Columbia, but D.C. should not have its own chart.
- Values above the national average should start with a + and and below should start with a -
- The national average is the line you see at 0%.
- This is NOT a trellis chart, but if you think you can make it work as a trellis chart, go for it!
- The area above zero should be shaded. The hex code to use is #F7E6E2 and it should be shaded from 0- to +10%.
- Pay attention to the gaps between each State. I like how this gives it some breathing room.
This will be a very tedious exercise. To provide some context, this took me 2-3 hours to create. Don’t get discouraged and don’t feel like you have to do it all in one sitting. Basically, try to make yours look identical to mine.
Post an image on Twitter when you’re done and hashtag it with #WorkoutWednesday and please tag me so I see it. You can also comment below with a link to your workbook or with any questions you have. Good luck!
August 10, 2012
Displaying time-series data: Stacked bars, area charts or lines…you decide!
First, let me say that this is a tremendous improvement over those produced by the U.S. Bureau of Alcohol, Tobacco, Firearms and Explosives (a.k.a. the ATF). Don’t bother reading the ATF report, unless you love 3D bar charts and 3D pie charts created in Excel.
A stacked bar chart is basically a pie chart unrolled to make a stick. And more often than not, when plotted as a time series, they do a poor job at showing the overall trends. Stacked bars are good up to three bars, no more. Why? Because it’s difficult to compare the heights of any of the bars except for the bottom bar, rifles in this case.
Let’s go through several alternative displays. If you’re interested in playing with the data, Matt published it here for me. Thank you Matt!
All of the charts below were built with Tableau. You can view an interactive version of all of these charts here and download the workbook here.
Let’s start with a redesigned stacked bar chart that uses Tableau’s built-in color blind palette.
Can you see the trends for each of the weapons? Maybe an area chart would be better.
Well, ok. Now the trends are easier to see, right? Area charts certainly improve the ability to see trends over time, but there are only two trends that give an accurate reading:
- The line at the top of the bottom area, i.e., rifles.
- The top of the top chart, which represents the total.
We still don’t have the ability to see the trends for any weapon except for rifles.
Before you read on, take out a piece of paper and sketch what you think the trend is for shotguns (light blue) based on the area chart above.
Ok. Now let’s compare the area chart above with the area chart for shotguns.
Did you come close? I doubt you did. Why? Because the tops of each color are influenced by the size of the colors below it, therefore making gauging the true size of each individual color extremely difficult.
Here’s another way to prove it. I know this isn’t a good way to represent the data, but bear with me, I’m trying to prove a point. If I overlay lines for each weapon over the area chart, look how different the shapes of the lines become.
Like most time-series data, your best way to represent the data is nearly always going to be a line chart.
Using a line chart we can quickly make some observations:
- There was a three-year spike in the early 90s for pistols made and there’s been a similar, but longer, surge since 2006. What was the cause of the big decline in 1995? Was there a change in handgun laws in 2005 or 2006?
- Revolvers were on a steady 20-year decline until 2005-2006. Is this merely coincidental with the pistols? Possibly so, possibly not.
- Rifles have increased recently, but shotguns have decreased. Are people buying rifles instead of shotguns? Their rate of variance since 1994 has grown consistently and the gap continues to get wider.
Using a line chart, you’re immediately asking questions of your data. Rapid-fire analysis!
When analyzing time-series data across several categories, consider not only looking at the raw numbers like above, but also review how each category contributes to the total. Let’s go through the same series of charts.
We’re off to a good start with the stacked bar chart. It looks like measuring the contribution of each weapon to the total may tell us something. Let’s try it as an area chart.
Not much better, other than it looks smoother. How about a line chart?
Ok, now we’re onto something. You might think that this is the same as the line chart for the raw numbers, and I can see how you might make that conclusion at a quick glance. But let’s look at them side-by-side.
The charts look very similar up until 1997, but then look at how many more rifles started to be made compared to the rest. And look at the drop off in percentage of shotguns produced since 2004.
Hopefully you’ve learned two main lessons:
- Don’t display time-series data as stacked bars (or pies unrolled onto on a stick if you prefer). The best medium for time-series data is a line chart.
- Consider looking at both the raw numbers and their contribution to the total. It’s always a good idea to look at your data in more than one way. You may get some additional and/or different insights.
Let me wrap with two charts that disturbed me a bit as I was playing with the data for this blog post. I’m not disturbed by their visual display, but by what they reveal.
The chart on the left is the running total of guns made by gun type since 1986. The chart on the right summarizes the chart on the left.
These charts tell us that the US has manufactured over 99 million guns since 1986. Seriously! 99 million! According to the US Census Bureau, there were ~238M Americans over 18. That means that approximately one of every five Americans 18 or older owns a gun.
That terrifies me!
Perhaps political interests (and lobbyists) have played a part?? For more information on how to use the US Census Bureau data, check out this guide.
UPDATE – Source CNN: This certainly explains the drop that started in 1994 and the subsequent increase in 2005.
The Clinton administration imposed a ban on several types of military-style semi-automatic rifles and high-capacity magazines in 1994, but that ban was allowed to lapse in 2004. Obama has proposed restoring the ban, requiring background checks for buyers at gun shows, and other "common-sense measures."
May 15, 2012
Tableau Tip: Create a beautiful heat map in under 30 seconds
This tip is a follow up to my post about asking How common is your birthday?. In this post, I created a heat map and Matt Stiles asked me if I could write a tutorial showing how I did it so quickly in Tableau.
The steps are for creating the viz only. I’m assuming you already connected to the data.
Step 1 – Hold the CTRL key and click the Day, Month and Rank fields (they should all be highlighted after you choose them)
Step 2 – Open the Show Me window on the toolbar and click on the Highlight Table option
You should see the view below with Days in the columns and Months in the rows.
Step 3 – Click on the swap icon to place Day on the row shelf and the Month on the column shelf
Step 4 – Right click on the Month column label and choose Hide Field Labels for Columns
Step 5 – Drag the Rank measure off of the Label shelf
You should now this view.
Step 6 – Double click the color shelf to show the Edit Colors window. Choose Orange from the Pallet list and the Reversed option, then click OK.
You need to choose the reverse option if you want the highest ranking days to be the darkest. You final view should look like this.
That’s it! Six steps, less than 30 seconds, and you have a beautiful heat map.
Give it a shot.
May 14, 2012
How common is your birthday? Find out exactly with an interactive heat map.
Matt Stiles posted a heat map on his blog yesterday that I thought was pretty well done. I decided to get the data from NYTimes.com and recreate it in Tableau.
It takes under 20 seconds and under 10 clicks to create it in Tableau, more like 15 seconds if you’ve been using Tableau longer.
Matt chose a brownish color palette, but I wanted to try lots of different colors. Tableau makes is incredibly simple to try out many options very quickly. I tested green, blue, gray and orange-blue palettes before settling on an orange palette. For my eye, the orange palette made distinguishing the colors easiest.
Creating this as an interactive viz in Tableau allows you to provide the reader/viewer/interactor with more information. Hover over your birthday and you will see exactly where it ranks. Try it!
In a static version, you’re left to guess at the approximate range in which it falls.
- Matt struggled with getting the colors just right using Illustrator. With Tableau, it’s all built in. There’s no need to tinker.
- Doctors apparently don’t like having their vacations disturbed. Check out how around major holidays (July 4th, Thanksgiving, Christmas) there a fewer babies born.
- September clearly has many of the top days (in fact it has all of the top 10), but July and August aren’t far behind. It looks like people conceive during all of those Thanksgiving, Christmas and New Year’s parties.
- A reader noted that the 13th seems to be least common on average. Perhaps that’s because many people see that as an unlucky day.
April 19, 2012
Visualizing the Remarkable Declines in U.S. Teenage Pregnancies
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.
I then:
- 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.