Examples of Basic Charts

Post on: 6 Июль, 2015 No Comment

Examples of Basic Charts

by Ben Lorica (last updated Apr/2012)

Beyond simple averages: The Median and the Interquartile Range

Whenever possible, I like to draw charts that provide visual representations for both averages and deviations. There are several standard options available, such as boxplots, histograms, or even approximate density functions. I have found that simply drawing the middle 50% of a distribution, in addition to highlighting the median, does a pretty good job of capturing variation and average behavior. It has the added benefit of being easy to explain. the bar represents the region from the 25th to the 75th percentile, and the red LINE is the median.

Below is an example of such a chart. Data is from the Dow Jones / Credit Suisse Hedge Fund Indices, and are the statistics for the monthly (percentage) returns from Jan/2006 to Aug/2011. As you can see, it’s very easy to pick out highly-volatile trading styles — simply look at the width of the bars! For another example, see the following chart from my page on Decision 2012.

Static, Stacked Bar Chart (with Title & Legend)

The creators of d3 provide an example a bar chart, that transitions between a stacked & grouped layout. I’ve already provided a separate example of a static, grouped (horizontal) bar chart. Here is an example of a static, stacked (vertical) bar chart, with accompanying legend and title.

Over the most recent quarter, combined revenue from iPhones and iPads exceeded $19 Billion! iPod revenues are relatively smaller, although there is a noticeable spike during the Christmas Holidays (Q1 of Apple’s fiscal year).

Annotated Stacked Bar Charts (magazine-style)

Dot Plot: Annotated & Color-coded Markers

Multiple Histograms: Trellis-style Comparison

From the time I started using S/S-Plus, I found myself relying on Trellis displays. the use of common axes to display relationships & distributions, conditional on values of other variables. I find this graphical style useful in exploring data sets with many variables and observations. Luckily Trellis graphs are very easy to create in R, and other statistics packages. This next example is an attempt to render something similar in d3.

Below is what histograms of a variable look like for three distinct values of the country variable (these conditional distributions use fake data). For special effects, I added a transition element, which you see in action if you reload the page by clicking on the reload button below:

Basic Treemap: U.S. Unemployment & Elections

I took the treemap example that comes with d3, and I fed it different data and tweaked the colors and labels. In the example below, the size and color of the squares are as follows:

Examples of Basic Charts
  • Electoral Votes. Size (number of electoral college votes ), Color (year-over-year change in unemployment rate from Jun/2010 to Jun/2011; green corresponds to an improvement/decrease, red corresponds to a worsening/increase)
  • Population. Size (state population), Color (current classification as a Red / Blue / Purple state ) You’ll notice that relative to their population size, smaller states have a larger share of electoral votes. (Use the buttons below to toggle back and forth between the two views.)

    Electoral Votes Population

    Time-series: Line chart from Finance/Economics

    In this example I wanted to create charts common in finance and economics. In finance, many time-series charts display related series — such as a stock price chart, with trading volume underneath. Economists like to display time-series charts with some temporal regions higlighted, such as periods when an economy is in recession.

    In the chart below, I tried to do both. The data set was big enough, that in order to get a bar chart effect for the bottom graph, I only drew bars twice a year (otherwise the bars would be too thin or appear as an area chart).

    I highlighted the two terms of Reagan and Clinton, as well as the 4-month period prior to November of their re-election years. Notice that under Reagan unemployment surged close to 11%, but by the time he ran for re-election, unemployment was falling and hovered around 7.5%. Under Clinton unemployment trended down, and during his re-election campaign it was around 5.2%. I also higlighted the period during the re-election campaigns of Bush I & II. Clinton’s predecessor (Bush I) ran at a time when unemployment had just peaked. In contrast Bush II ran for re-election when unemployment was around 5.5%.


  • Categories
    Options  
    Tags
    Here your chance to leave a comment!