Apr 22, 2011

Fancy Chart How-To: Ethnicity in America

After the series on money and careers this week, I needed some mindless blogging I could churn out without too much thought. This post is mostly just an excuse to try out some interactive charts. I first saw these on the Artemis Project blog. It's another hobbyist project doing cutting edge analysis of genetic tests, like the Eurogenes, Dodecad, and Harappa Ancestry projects. The graphics on both the Artemis and Harappa projects really stood out. At first, I was impressed, and wondered how they created them. I discovered it's actually very easy using spreadsheets on Google Docs. I'll use an example chart I made from census data, then explain how to create your own.

The subject of this post is a simple breakdown of the top 20 ethnicities of Americans in the 2000 US Census. Such macro-level demographic data might not sound very useful, but combined with county-level maps (see below), it can help find likely places an ancestor might have settled, or passed through, after immigrating to America. During the late 19th and early 20th century, new immigrants tended to stick together with people from their own ethnicity for a generation or so. Many of them didn't initially speak English, so they wanted to live near others they could communicate with.

Data from the 2000 US Census, and previous ones, are available to download from the Census Bureau. If you explore their website, you can find all kinds of data, for the country as a whole and separate geographical divisions. Also keep in mind that "ancestry," as the census records it, is self-reported. So take it for what it's worth. Here's a chart I created from the data. If you move your mouse over the bars, tooltips will popup and display the actual percentages:To make your very own charts like the example above (or far more complex ones), either import an existing spreadsheet into Google Docs, or create a new one. Editing spreadsheets there works much like Microsoft Excel, so I'm not going to explain that. Once you've entered some data, created a chart from it, and edited its appearance to your liking, you're ready to embed it in a web page.

Here's how it works: Use the "Publish chart..." command under the pull-down menu on the chart itself (see left). It pops up a message with the HTML code to embed in any web page (see right). Just copy the text and paste it into the source code of the web page where you want to display the chart. For example, if you're embedding it in a post here on Blogger, click the "Edit HTML" tab at the top of the editor. Don't be alarmed it doesn't show up in the "Compose" mode. The editor doesn't execute the script needed to display the chart. When you preview or publish the post, the chart will display correctly. I must add one minor caveat, that might require some hand-editing of the code. On my blog, the main content column is too narrow to fit the default chart size. However, if you look at the source code for the chart, there are some easily understandable parameters for height and width. In my case, the original code from Google Docs specified "width":600. Just experiment with different numbers to find a value that fits.

There are a wide variety of maps created from census data on Wikipedia. For example, here's a breakdown of all 3143 counties/parishes in the US, color-coded by the predominant ethnicity reported:

This is an extremely simple example of the kind of great looking, interactive charts made possible by Google Docs. As a follow-up to this post, I'll create another chart with the ethnicity of Minnesotans. Eventually, I want to make some fancy genetic admixture charts like the aforementioned genome bloggers, but I'm still just experimenting with the software for now.

No comments:

Post a Comment