# Posts for Tag: visualization

### How do Americans Spend Money? US Household Spending Breakdown by Income Group

Posted In: Money
##### How much do US households spend?

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 income of the household.

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.

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.

Instructions:

• 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 income. This data breaks households into quintiles (groups of 20%) by income. The lowest quintile group is the group of 20% of households with the lowest income (and spend on average ~$25,500/yr). As stated before, one of the keys to financial security is spending less than your income. We can see that on average, those in the lowest quintiles may be borrowing or drawing down on savings to live their lifestyle, while those in the highest quintiles are saving money and contributing to wealth. This fairly high level of borrowing/drawing on savings from the lowest quintile households may be deceptive because it includes seniors who are drawing down savings that were built up specifically for this purpose, and college students who are borrowing to go to school. These groups generally don’t have significant incomes. How does your overall spending compare with those in your income group? 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 just make a table or pie chart or whatever. 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. ### Understanding Tax Brackets: Interactive Income Tax Visualization Posted In: Money ##### How is your income distributed across tax brackets? I previously made a graphical visualization of income and marginal tax rates. That graph tried to show alot of info on the same graph, i.e. the breakdown of income tax brackets for incomes ranging from$10,000 to $3,000,000. It was nice looking, but I think several people were confused about how to read the graph. This Sankey graph is a more detailed look at the tax breakdown for one specific income. You can enter your (or any other) profile and see how taxes are distributed across the different brackets. It can help (as the other tried) to better understand marginal and average tax rates. This tool only looks at US Federal Income taxes and ignores state, local and Social Security/Medicare taxes. – Use this button to generate a URL that you can share a specific set of inputs and graphs. Just copy the URL in the address bar at the top of your browser (after pressing the button). Instructions for using the visual tax calculator: • Select filing status: Single, Married Filing Jointly or Head of Household. For more info on these filing categories see the IRS website • Enter your regular income and capital gains income. Regular income is wage or employment income and is taxed at a higher rate than capital gains income. Capital gains income is typically investment income from the sale of stocks or dividends and taxed at a lower rate than regular income. • Move your cursor or click on the Sankey graph to select a specific link. This will give you more information about how income in a specific tax bracket is being taxed. • #### **Click Here to view other financial-related tools and data visualizations from engaging-data** As seen with the marginal rates graph, there is a big difference in how regular income and capital gains are taxed. Capital gains are taxed at a lower rate and generally have larger bracket sizes. Generally, wealthier households earn a greater fraction of their income from capital gains and as a result of the lower tax rates on capital gains, these household pay a lower effective tax rate than those making an order of magnitude less in overall income. Here are two tables that lists the marginal tax brackets in the United States in 2018 that form the basis of the calculations in the calculator. 2019’s numbers are pretty similar. US Tax Brackets and Rates for 2018 Rate Single Taxable Income Over Married Filing Joint Taxable Income Over Heads of Households Taxable Income Over 10%$0 $0$0
12% $9,525$19,050 $13,600 22%$38,700 $77,400$51,800
24% $82,500$165,000 $82,500 32%$157,500 $315,000$157,500
35% $200,000$400,000 $200,000 37%$500,000 $600,000$500,000

You can see that tax rates are much lower for capital gains in the table below than for regular income (table above).

Capital Gains Brackets for 2018
Single
Capital Gains Over
Married Filing Jointly
Capital Gains Over
Capital Gains Over
0% $0$0 $0 15%$38,700 $77,400$51,850
20% $426,700$480,050 $453,350 For those not visually inclined, here is a written description of how to apply marginal tax rates. The first thing to note is that the income shown here in the graphs is taxable income, which simply speaking is your gross income with deductions removed. The standard deduction for 2018 range from$12,000 for Single filers to $24,000 for Married filers. • If you are single, all of your regular taxable income between 0 and$9,525 is taxed at a 10% rate. This means that your all of your gross income below $12,000 is not taxed and your gross income between$12,000 and $21,525 is taxed at 10%. • If you have more income, you move up a marginal tax bracket. Any taxable income in excess of$9,525 but below $38,700 will be taxed at the 12% rate. It is important to note that not all of your income is taxed at the marginal rate, just the income between these amounts. • Income between$38,700 and $82,500 is taxed at 24% and so on until you have income over$500,000 and are in the 37% marginal tax rate . . .
• Thus, different parts of your income are taxed at different rates and you can calculate an average or effective rate (which is shown in the summary table).
• Capital gains income complicates things slightly as it is taxed after regular income. Thus any amount of capital gains taxes you make are taxed at a rate that corresponds to starting after you regular income. If you made $100,000 in regular income, and only$100 in capital gains income, that $100 dollars would be taxed at the 15% rate and not at the 0% rate, because the$100,000 in regular income pushes you into the 2nd marginal tax bracket for capital gains (between $38,700 and$426,700).

Data and Tools:
Tax brackets and rates were obtained from the IRS website and calculations were made using javascript and code modified from the Sankeymatic plotting website.

### Visual Guide to Understanding Marginal Tax Rates

Posted In: Money

##### What is a marginal tax rate?

There is a fair amount of confusion about what a marginal tax rate is and how it affects how much tax you would owe the government on a certain amount of income. These graphs are here to help you better understand the difference between a marginal and average tax rate and to easily calculate these rates for specific examples in the US context. This tool only looks at US Federal Income taxes and ignores state, local and Social Security/Medicare taxes.

Marginal tax rates are the rate at which an additional dollar of income will be taxed at. There are different tax brackets (each with its own marginal rate) depending on which dollar of income you are looking at. This is very different from the Average (or effective) tax rate that is the result of applying these marginal tax rates across all of your income.

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

Instructions for using the visual tax calculator:

• Select filing status: Single, Married Filing Jointly or Head of Household. For more info on these filing categories see the IRS website
• Select percentage of regular income vs capital gains income. Regular income is wage or employment income and is taxed at a higher rate than capital gains income. Capital gains income is typically investment income from the sale of stocks or dividends and taxed at a lower rate than regular income.
• Move your cursor or click on the graph to select a specific income Make sure you note that the x-axis is a logarithmic-scale, meaning that income grows exponentially as you move to the right.
• Choose your graph preference One graph (Individual Tax Brackets) shows the individual tax brackets and how much of your income is taxed at the different marginal rates. The other graph (Aggregate Rates) shows the net result of applying the different rates to get your effective rate.
One of the most interesting things is to vary the proportion of regular income vs capital gains taxes. Generally, wealthier households earn a greater fraction of their income from capital gains and as a result of the lower tax rates on capital gains, these household pay a lower effective tax rate than those making an order of magnitude less in overall income.

Here are two tables that lists the marginal tax brackets in the United States in 2019 that form the basis of the calculations in the calculator. 2018’s numbers are pretty similar.

US Tax Brackets and Rates for 2019
Rate Single
Taxable Income Over
Married Filing Joint
Taxable Income Over
Taxable Income Over
10% $0$0 $0 12%$9,700 $19,400$13,850
22% $39,475$78,950 $52,850 24%$84,200 $168,400$84,200
32% $160,725$321,450 $160,700 35%$204,100 $408,200$204,100
37% $510,300$612,350 $510,300 You can see that tax rates are much lower for capital gains in the table below than for regular income (table above). Capital Gains Brackets for 2019 Single Capital Gains Over Married Filing Jointly Capital Gains Over Heads of Households Capital Gains Over 0%$0 $0$0
15% $39,375$78,750 $52,750 20%$434,550 $488,850$461,700

For those not visually inclined, here is a written description of how to apply marginal tax rates. The first thing to note is that the income shown here in the graphs is taxable income, which simply speaking is your gross income with deductions removed. The standard deduction for 2019 range from $12,200 for Single filers to$24,400 for Married filers.

• If you are single, all of your regular taxable income between 0 and $9,700 is taxed at a 10% rate. This means that your all of your gross income below$12,200 is not taxed and your gross income between $12,200 and$21,900 is taxed at 10%.
• If you have more income, you move up a marginal tax bracket. Any taxable income in excess of $9,700 but below$39,475 will be taxed at the 12% rate. It is important to note that not all of your income is taxed at the marginal rate, just the income between these amounts.
• Income between $39,475 and$84,200 is taxed at 24% and so on until you have income over $510,300 and are in the 37% marginal tax rate . . . • Thus, different parts of your income are taxed at different rates and you can calculate an average or effective rate (which is shown in the aggregate rates graph). • Capital gains income complicates things slightly as it is taxed after regular income. Thus any amount of capital gains taxes you make are taxed at a rate that corresponds to starting after you regular income. If you made$100,000 in regular income, and only $100 in capital gains income, that$100 dollars would be taxed at the 15% rate and not at the 0% rate, because the $100,000 in regular income pushes you into the 2nd marginal tax bracket for capital gains (between$39,375 and \$434,550).

Data and Tools:
Tax brackets and rates were obtained from the IRS website and calculations were made using javascript and plotted using the plot.ly open source javascript plotting library.

### Interactive California Reservoir Levels Dashboard

Posted In: Environment | Water

It’s the winter rainy season in California again, so time to check on the status of the water in the California reservoirs. I previously made a “bar graph” showing the overall level of water in the major California reservoirs. This dashboard provides a bit more detail on the state of each of the reservoirs while also showing an aggregate total. It updates hourly using data from the California Department of Water Resources (DWR) website, giving an up-to-date picture of California reservoir levels.

This is a marimekko (or mekko) graph which may take some time to understand if you aren’t used to seeing them. Each “row” represents one reservoir, with bars showing how much of the reservoir is filled (blue) and unfilled (brown). The height of the “row” indicates how much water the reservoir could hold. Shasta is the reservoir with the largest capacity and so it is the tallest row. The proportion of blue to brown will show how full it is, while the red line shows the historical level that reservoir is typically at for this date of the water year. There are many very small reservoirs (relative to Shasta) so the bars will be very thin to the point where they are barely a sliver or may not even show up.

Instructions:
If you are on a computer, you can hover your cursor over a reservoir and the dashboard at the top will provide information about that individual reservoir. If you are on a mobile device you can tap the reservoir to get that same info. It’s not possible to see or really interact with the tiniest slivers. The main goal of this visualization is to provide a quick overview of the status of the main reservoirs in the state and how they compare to historical levels.

You can sort the mekko graph by size – largest at the top to smallest at the bottom – or by reservoir location, from north to south.

Units are in kaf, thousands of acre feet. 1 kaf is the amount of water that would cover 1 acre in one thousand feet of water (or 1000 acres in water in 1 foot of water). It is also the amount of water in a cube that is 352 feet per side (about the length of a football field). Shasta is very large and could hold about 3.5 cubic kilometers of water at full (but not flood) capacity.

Data and Tools
The data on water storage comes from the California Department of Water Resources’ (DWR) Data Exchange Center. Python is used to extract the data from this page hourly and wrangle the data in to a clean format. Visualization was done in javascript and specifically the D3.js visualization library. It was my first time using D3 and it took me a long time to get up to speed. It takes a fair amount of work to make graphs compared to other more plug-and-play libraries but its very customizable, which is a plus. It was the only tool that I could find that would allow me to make a vertical marimekko graph.

### Antipodes map: What’s on the other side of the Earth?

Posted In: Fun | Maps

#### What is an antipode?

An antipode is a point that is on the exact opposite side of the earth (or other sphere) from a given location. If you drew a line (vector) from your location to the center of the earth and continued that line until it emerged from the other side of the earth’s surface, that point of intersection on the other side is the antipode. When I was a kid, people occasionally mentioned “digging a hole to China”. While this is currently impossible for many reasons1Earth’s core is about 6000 degrees C, China is not the antipode for North America (where I grew up). If you grew up in Argentina or Chile, then maybe that would make a little more sense.

The antipodes for most of North America and Europe are in the Indian and South Pacific oceans respectively.

Other examples of antipodes that are both on land:

#### Instructions:

It should be relatively explanatory, but you find your location by dragging the globe on the left side so that your location is in the center crosshair. The other globe (on the right) will show you the antipode to your location.
You can zoom in and out with the +/- buttons or pinch to zoom on mobile. If you zoom in enough, it will look like a normal two-dimensional web map (like google maps).

Tools:
This interactive visualization is made using the awesome webglearth javascript library. I just discovered this recently after making a number of 2D maps.

Footnotes   [ + ]

 1 ↑ Earth’s core is about 6000 degrees C

### Scaling the physical size of States in the US to reflect population size (animation)

Posted In: Maps
##### States sized to New Jersey’s population density

Choropleth maps are a pretty useful kind of map that colors distinct areas of the map (e.g. states, counties or countries) to reflect different numerical or categorical values. It is useful to show differences across geographic regions. I’ve been making a bunch of these recently (stressed states, bitcoin electricity consumption, college admissions). One of the issues that can be problematic with these maps is that some regions can be very large but only have very few people. If the choropleth map is tracking a intensity value (like CO2 emissions per capita), a large area with a high color value might visually indicate that total emissions (emissions per capita x # of people) is also high. In the US this is reflected in states like Alaska, Montana and Wyoming, which are large but have very few people.

I decided to make a modified choropleth map (updated after learning that it’s called a cartogram) that scales the size of the states to be the proportional to the state’s population. States with larger populations show up as larger. This is equivalent to making each state have the same population density. Since New Jersey has the highest population density of any state in the US (1200 people/square mile), it stays the same size in this map and all the other states shrink, to reflect their lower population density. For example, California has a larger population than NJ (4.4x), but its physical size is about 20x larger. So California is shrunk to about 20% its original size to make its physical size 4.4x the size of NJ.

The states are also colored to show population as well (darker redder colors reflect larger population while yellow/beige reflects small populations).

##### States sized to California’s population density

Living in California, I decided to make another animation, this time with scaled to the density of California, so some states that are less dense will shrink, while others that are denser will grow. New Jersey grows quite a bit. Because many of the dense Northeast states grow a bit, I had to space them out (manually) so you could still see them otherwise they’d overlap too much.

Data Sources and Tools:
2015 population and population density data comes from Wikipedia and leaflet.js open source mapping library was used to create the maps. State outlines in geoJSON format come from leaflet. Javascript code was used to scale the coordinates of the geoJSON polygons to the appropriate size and animate the map.