Saturday, November 15, 2008

Thermometer plots in R

R has the ability to create thermometer plots. I first heard of these from "The Elements of Graphing Data" by William Cleveland. In fact I created some by hand before I realized that they are built into R's 'symbols' function. (They are not difficult to make by hand and of course give you some more flexibility.)

Here is an example, based on Problem 2.40 from "Statistics and Experimental Design in Engineering and the Physical Sciences," by Johnson and Leone.
A Roper Report issued in 1974 estimated that citizens (in the percentages indicated below) would not object to (1) a government agency filling a sensitive job, (2) a private company, (3) local police, or (4) a "credit card company" having the following data:
(1)(2)(3)(4)
Employment records74642744
Psychiatric history66383410
Health records64502513
Memberships, Associations5320227
Traffic violations4319508
Tax returns39131510
Sexual history3112205

Represent these data pictorially, and comment.

A typical way is a clustered column chart (Excel's term). But which way to cluster?



or


In either case, it is sort of easy to compare within clusters, but less so across clusters. The color helps, but in either case things are cluttered. The separated legend requires you to look back and forth.

The thermometer plot has a 3-D layout for this 3-D data.



I find it easy to scan the rows and the columns in this plot.
Other 3-D arrangements I've seen use either scaled bubbles or pie charts instead of thermometers. The problem with bubbles is that the scale is not so intuitive; do you scale the bubbles by radius or area? (Excel offers both options.) The thermometer varies cleanly in one dimension. Which is easier to read than the angles in pie charts.

Of course, the thermometers can also be used to plot a third dimension on an x-y-z plot or on a map, rather than a regular grid of categories like this example.

UPDATE 11/16:
The example thermometer could be done in Excel.



But not so easy to put them on an x-y-z plot or a map.

4 comments:

  1. Hello

    I wonder how you created those thermometers in excel. Are they charts or autoshapes? It would be great if you could post an excel file that shows the way you did it?

    John

    ReplyDelete
  2. John, it is a chart. Details posted above.

    ReplyDelete
  3. Hi David

    A very detailed explanation. Thank you very much.

    John
    2008-11-30

    ReplyDelete
  4. I ran across this post, but could not reproduce using base R and symbols {graphics} function.

    I posted your data on StackOverflow. See answer with ggplot2 code.

    https://stackoverflow.com/questions/53787540/plot-thermometer-graph

    ReplyDelete