Posts for Tag: interactive

How do Americans Spend Money? US Household Spending Breakdown by Education Level

Posted In: Money
How much do US households spend and how does it change with education level?

This visualization is one of a series of visualizations that present US household spending data from the US Bureau of Labor Statistics. This one looks at the education level of the primary resident.

This visualization focuses on the education level of the primary resident. This is defined in the BLS documentation as the person who is first mentioned when the survey respondent is asked who in the household rents or owns the home.

I obtained data from the US Bureau of Labor Statistics (BLS), based upon a survey of consumer households and their spending habits. This data breaks down spending and income into many categories that are aggregated and plotted in a Sankey graph.

One of the key factors in financial health of an individual or household is making sure that household spending is equal to or below household income. If your spending is higher than income, you will be drawing down your savings (if you have any) or borrowing money. If your spending is lower than your income, you will presumably be saving money which can provide flexibility in the future, fund your retirement (maybe even early) and generally give you peace of mind.


  • Hover (or on mobile click) on a link to get more information on the definition of a particular spending or income category.
  • Use the dropdown menu to look at averages for different groups of households based on the education level of the primary resident. This data breaks households into the following groups:
    • All
    • Less than HS graduate
    • High school graduate
    • HS grad + some college
    • Associate’s degree
    • Bachelor’s degree
    • Master’s, professional, doctoral degree

    The composition of households and income change as the education level of the primary resident changes, which in turn affects spending totals and individual categories.

As stated before, one of the keys to financial security is spending less than your income. We can see that on average, income tends to increase with education level. Those with the highest incomes and greatest spending have advanced degrees, but they also save the most money.

The group with the lowest education level (not finishing high school) have the lowest income and on average needs to borrow or draw down on savings to live their lifestyle.

How does your overall spending compare with those that have the same education level as you? How about spending in individual categories like housing, vehicles, food, clothing, etc…?

Probably one of the best things you can do from a financial perspective is to go through your spending and understand where your money is going. These sankey diagrams are one way to do it and see it visually, but of course, you can also make a table or pie chart (Honestly, whatever gets you to look at your income and expenses is a good thing).

The main thing is to understand where your money is going. Once you’ve done this you can be more conscious of what you are spending your money on, and then decide if you are spending too much (or too little) in certain categories. Having context of what other people spend money on is helpful as well, and why it is useful to compare to these averages, even though the income level, regional cost of living, and household composition won’t look exactly the same as your household.

**Click Here to view other financial-related tools and data visualizations from engaging-data**

Here is more information about the Consumer Expenditure Surveys from the BLS website:

The Consumer Expenditure Surveys (CE) collect information from the US households and families on their spending habits (expenditures), income, and household characteristics. The strength of the surveys is that it allows data users to relate the expenditures and income of consumers to the characteristics of those consumers. The surveys consist of two components, a quarterly Interview Survey and a weekly Diary Survey, each with its own questionnaire and sample.

Data and Tools:
Data on consumer spending was obtained from the BLS Consumer Expenditure Surveys, and aggregation and calculations were done using javascript and code modified from the Sankeymatic plotting website. I aggregated many of the survey output categories so as to make the graph legible, otherwise there’d be 4x as many spending categories and all very small and difficult to read.

household spending

What kinds of vehicles do Americans drive?

Posted In: Energy

Americans are known for loving cars and driving quite a bit. Drivers in the United States own more cars and drive more than those in any other country. So what kinds of vehicles do Americans drive? This visualization looks at the types of vehicles (by body type and country of origin) across the 50 States and Washington DC.

You can view two different attributes about the types of vehicles in use in the United States:

  • Body type of passenger vehicles
  • Manufacturer/Brand region of origin

The different categories of passenger vehicles include:

  • Cars – includes sedans, hatchbacks, wagons and sports cars
  • Pickup trucks
  • SUVs
  • Vans – includes Minivans and full-size vans

Classification of the vehicles manufacturer (US, Asia or Europe) is based on the company’s headquarters and not the place of vehicle manufacturing. So a Toyota here is an Asian vehicle even if it was assembled in Mississippi.

It is pretty interesting to see the regional differences in vehicle types (cars vs trucks and SUVs) and vehicle brand (domestic vs foreign). Michigan, especially, stands out with their very high domestic ownership. It makes sense as Detroit is the home of the big three US auto manufacturers (Ford, GM and Chrysler). And I hear there’s a very strong culture of owning American cars there (and employee, friends and family discounts as well).

The data is derived from a survey by the US Department of Transportation called the National Household Travel Survey (NHTS) released in 2017. The following is a quote from the NHTS webpage:

The National Household Travel Survey (NHTS) is the source of the Nation’s information about travel by U.S. residents in all 50 States and Washington, DC. This inventory of travel behavior includes trips made by all modes of travel (i.e., private vehicle, public transportation, pedestrian, and cycling) and for all purposes (e.g., travel to work, school, recreation, and personal/family trips). It provides information to assist transportation planners and policymakers who need comprehensive data on travel and transportation patterns in the United States.

Data and Tools:
Data, as stated before, comes from the US Department of Transportation’s National Household Travel Survey (NHTS). That data was processed to identify vehicle characteristics by state and plotted using javascript and the open-source leaflet map library.

car types by state

What are the highest mountains on Earth? Measuring from sea level vs center of earth

Posted In: Geography

The Highest Mountains On Earth Depend On How You Measure “High”

Mount Everest is famous for being the highest mountain on Earth. The peak is an incredible 8,848 meters (29,029 ft) above sea level. But that is only one way to measure the height of a mountain. Chimborazo, a mountain in Ecuador, holds the distinction for the mountain whose peak is the furthest from the center of the Earth. How is that possible? This is because the Earth is not a perfect sphere. Rather, due to the spinning of the Earth around it’s axis, the centrifugal force causes the equator to bulge out slightly. This flattened shape is called an oblate spheroid and makes the radius of the earth at the equator about 22 km (about 0.3%) larger than the radius to the poles. Mountains close to the equator will “start” further away from the center of the earth, than those at higher latitudes.

This graph plots over 800 of the highest mountains on Earth with their peak height above sea level on the x-axis and their peak distance from the center of the earth on the y-axis. Each point represents one mountain. The colors of the plots correspond to the latitude of the mountain. These mountains range from 3000 meters in height to 9000 meters in height. You can hover over a data point (or click on mobile) to get more information about the mountain. You can also switch from metric to imperial units with the button on the graph.

For a given mountain range at a certain latitude, you can see that as the mountain heights above sea level increases, so does their distance from the center of the Earth. Mountains in the southern hemisphere are colored in blue, those around the equator are green and yellow, and those in the northern hemisphere are red and orange. The mountains with the highest peaks above sea level are shown on the right side of the graph in red and orange (mostly in the Himalaya), with Mt Everest as the right most point on the graph (nearly 9000 meters tall).

Mountains with peaks the greatest distance from the center of the earth are found near the equator in light green/yellow and are found at the top of the graph. You’ll notice that a number of these mountains are higher than Mt Everest when looking at the distance from the center of the earth.

The Himalayas are the “highest” mountains on earth if you are measuring height from sea level, while the Andes are the “highest” if you measure from the center of the earth.


Calculating Distance from Earth’s Center to Mountain Peak

The distance from the center of the Earth is calculated from the following formula:
$$D_{mountain} = H_{mountain} + R_{lat}$$
where $D_{mountain}$ is the distance from center of earth to the top of the mountain, $H_{mountain}$ is the mountain height above sea-level and $R_{lat}$ is the radius of earth at the mountain’s latitude. The height is data that was downloaded from a list of mountain heights.

and the radius of the earth for a given latitude is calculated using the formula:
$$R_{lat}=\sqrt{a^2cos(lat)^2+b^2sin(lat)^2\over acos(lat)^2+bsin(lat)^2)}$$
where $a$ and $b$ are the equatorial and polar radii (6378.137 km and 6356.752 km respectively).

Earth Radius Calculator

Here is a calculator for determining the radius of Earth at a given latitude:

You can use this to calculate the distance from the center of the earth to sea level at your latitude.


Data and Tools:
Data on the heights of over 800 mountain peaks over 3000 meters in height was downloaded from Wikipedia. There ended up being alot of google searching and data cleaning to get it into suitable format for plotting. The calculations were made with javascript and plotted using plotly, the open source javascript graphing library.

Mountain Height Graph

How Much Does Each State Pay In Taxes?

Posted In: Money

Given that tax day has just passed, I thought it would be good to check out some data on taxes. The IRS provides a great resource on tax data that I’ve only just gotten into. I think I’ll be able to do more with this in the future. This one looks at how taxes paid varies by state and presents it as a choropleth map (coloring states based on certain categories of tax data).

You can choose from a number of different categories:

  • Mean Federal Tax Paid
  • Mean Adjusted Gross Income
  • Mean State/Local Tax
  • Mean Combined (Fed/State/Local) Tax
  • Percent Income from Dividends and Capital Gains
  • Percent of Returns with Itemized Deductions
  • Number of Tax Returns
  • Mean Federal Tax Rate
  • Mean State/Local Tax Rate
  • Mean Combined (Fed/State/Local) Rate
  • Total Federal Tax Liability

I may add more categories in the future, so if you have ideas of tax data you want to see visualized let me know and I’ll see what I can do.

For other tax-related tools and visualizations see my tax bracket calculator and visualization of marginal tax rates.

**Click Here to view other financial-related tools and data visualizations from engaging-data**

Data and Tools:

Data on tax returns by state is from the IRS website in an excel format. The map was made using the leaflet open source mapping library. Data was compiled in excel and calculations made using javascript.

How much each state paid in taxes

Code Embed: Cannot use CODECSSresize9 as a global code as it is being used to store 2 unique pieces of code in 3 posts

Mercury is the closest planet to Earth (on average)

Posted In: Science

We all learned the order of planets in school. In my case using the mnemonic, My Very Excellent Mother Just Served Us Nine Pizzas (MVEMJSUNP) for Mercury, Venus, Earth, Mars Jupiter Saturn, Uranus, Neptune, and Pluto. Since Pluto has been demoted to a dwarf planet, you could change the Nine Pizzas to Noodles or something else.

And in terms of distances, Venus’s orbit (0.72 AU, or Astronomical Units (i.e. 1 AU is the distance from the Earth to the Sun) is closer to Earth’s orbit (1 AU by definition) than Mercury’s (varies between 0.31 and 0.47 AU because of it’s more elliptical orbit) or Mars’ (1.5 AU).

However, I saw an article, stating that Mercury might in fact be the closest planet to Earth (on average) so I thought I’d whip up a visualization that shows which planet is closest as a function of the planetary orbits around the sun.

Because of where the planets are on these orbital paths, and specifically the time it takes Mercury to orbit the sun, Mercury is the planet that is closest to Earth more often and has an average distance to Earth that is lower than the other 2 inner planets. Mars is occasionally the closest as well, but on average much further than Mercury or Venus. Also interesting is that Mercury is, on average, about 1 AU away from Earth, which is the same as the distance to the Sun.

This simulation shows how the planet positions vary each day over a 30 year period and the regularity with which the distance between Earth and the other varies over time. Mercury has the shortest period while Mars has the longest. You can change the speed of the simulation to speed up or slow down the orbits of the planets.

Data and Tools:
I thought about simulating the planets but there are plenty of tools out there that generate this orbital data so instead just downloaded ephemeris data (data related to positions of astronomical bodies) from NASA website.. I processed the data using javascript and drew the picture using HTML canvas tools and made the distance vs time plot with the Plotly open source plotting javascript library.

Mercury is closest planet to Earth

Sizing the States Based On Electoral Votes

Posted In: Maps | Voting

Electoral Vote maps give more visual power to states with large areas but few electoral votes

This map shows the electoral outcome of the 2016 US Presidential Election and is color coded red if the state was won by Donald Trump (R) and blue if the state was won by Hilary Clinton. When looking at the map, red states tend to be larger in area than blue states, but also generally have lower populations. This gives a misleading impression that the electoral share is “redder” than it actually is. For 2016, we can see that Trump won 306 electoral votes or (57% of the total electoral votes), but the map is shaded such that 73% of the area of the US is colored red. Similarly, Clinton won 232 electoral votes, but the map is shaded such that only 27% of the map is colored blue.

The map shrinks the states with low electoral votes relative to its area and increases the size of states with large numbers of electoral votes relative to its area. On average blue states grow as they are under-represented visually, while red states tend to shrink quite a bit because they are over-represented visually. Alaska is the state that shrinks the most and DC and New Jersey are the areas that grow the most in the new map.

I think this gives a more accurate picture of how the states voted because it also gives a sense of the relative weight of those states votes. Even with the change in sizes, the map is still mostly red, but gives a better sense of how close the electoral vote totals are.

Data and Tools:
Data on electoral votes is from Wikipedia. The map was made using the leaflet open source mapping library. Data was compiled and calculations on resizing states were made using javascript.

Re-sizing The Electoral Map