45
$\begingroup$

I usually make my own idiosyncratic choices when preparing plots. However, I wonder if there are any best practices for generating plots.

Note: Rob's comment to an answer to this question is very relevant here.

$\endgroup$

16 Answers 16

26
$\begingroup$

The Tufte principles are very good practices when preparing plots. See also his book Beautiful Evidence

The principles include:

  • Keep a high data-ink ratio
  • Remove chart junk
  • Give graphical element multiple functions
  • Keep in mind the data density

The term to search for is Information Visualization

$\endgroup$
3
  • 5
    $\begingroup$ Tufte's Visual Display of Quantitative Information (amazon.com/o/ASIN/0961392142/ref=nosim/gettgenedone-20) is better than Beautiful Evidence IMO. All four of his books are good though, and if you have an opportunity to attend one of his courses, do it. $\endgroup$ Jul 21, 2010 at 13:57
  • 7
    $\begingroup$ I agree with most of what Tufte says, but I have to say, his low data:ink boxplots are just plain idiotic. I think they take me 3-4 times longer to figure out than standard boxplots. The R defaults are much better (although the lines on the ends of the tails are unnecessary). Traditional boxplots have the added advantage that they can represent sample size (with width), and standard deviations (with notches). $\endgroup$
    – naught101
    Apr 20, 2012 at 1:12
  • 3
    $\begingroup$ +1 @ naught101 a few others share this opinion over at SO: stackoverflow.com/questions/6973394/… $\endgroup$
    – Ben
    Apr 20, 2012 at 5:41
15
$\begingroup$

We could stay here all day denoting best practices, but you should start by reading Tufte. My primary recommendation:

Keep it simple.

Often people try to load up their charts with information. But you should really just have one main idea that you're trying to convey and if someone doesn't get your message almost immediately, then you should rethink how you have presented it. So don't start working on your chart until the message itself is clear. Occam's razor applies here too.

$\endgroup$
2
  • 1
    $\begingroup$ I agree with the majority of this point, but I think "Keep it simple." could be unclear. Your main point is that you should know what you want the chart to convey. "Keep it simple." brings up some other ideas, like "The data:ink ratio should be high.", which Tufte encourages, and "Present no more than three variables.", which Tufte discourages. $\endgroup$ Jun 1, 2011 at 13:59
  • $\begingroup$ Clearly this advice is immensely better than the opposite. But there are situations in which a graph is necessarily complicated and requires detailed, careful, thoughtful study. But the complication should itself be as simple as possible. For example, 25 plots in a 5 x 5 matrix may need prolonged study, but the idea that each shows just some of the data is relatively easy to grasp. $\endgroup$
    – Nick Cox
    Sep 17, 2016 at 13:44
13
$\begingroup$

One rule of thumb that I don't always follow but which is on occasion useful is to take into account that it is likely that your plot will at some point in its future be

  • sent by fax,
  • photocopied, and/or
  • reproduced in black-and-white.

You need to try and make your plots clear enough that even if they are imprecisely reproduced in the future, the information the plot is trying to convey is still legible.

$\endgroup$
3
  • 19
    $\begingroup$ I think you mean sent by fax at some point in the past ;) $\endgroup$
    – hadley
    Jul 21, 2010 at 12:42
  • $\begingroup$ +1 for this. Your seminal plot, the heart of your paper, should not be utterly unintelligible because I printed it out. $\endgroup$
    – Fomite
    Dec 7, 2011 at 14:50
  • $\begingroup$ this answer addresses a similar problem. $\endgroup$
    – naught101
    Apr 20, 2012 at 1:36
9
$\begingroup$

In the physics field there is a rule that the whole paper/report should be understandable only from quick look at the plots. So I would mainly advise that they should be self-explanatory.
This also implies that you must always check whether your audience is familiar with some kind of plot -- I had once made a big mistake assuming that every scientist knows what boxplots are, and then wasted an hour to explain it.

$\endgroup$
1
  • 1
    $\begingroup$ Sympathies on the box plot experience, but what this implies is (a) use of a relatively simple variant (e.g. showing median, quartiles, 5% and 95% points and all data points beyond) rather than showing anything based on the convention centred on 1.5 IQR; (b) adding a caption making conventions explicit. $\endgroup$
    – Nick Cox
    Sep 17, 2016 at 13:48
8
$\begingroup$

In addition to conveying a clear message I always try to remember the plotsmanship:

  • font sizes for labels and legends should be big enough, preferably the same font size and font used in the final publication.
  • linewidths should be big enough (1 pt lines tend to disappear if plots are shrunk only slightly). I try to go to linewidths of 3 to 5 pt.
  • if plotting multiple datasets/curves with color make sure that they can be understood if printed in black-and-white, e.g. by using different symbols or linestyles in addition to color.
  • always use a lossless (or close to lossless) format, e.g. a vector format like pdf, ps or svg or high resolution png or gif (jpeg doesn't work at all and was never designed for line art).
  • prepare graphics in the final aspect ratio to be used in the publication. Changing the aspect ratio later can give irritating font or symbol shapes.
  • always remove useless clutter from the plotting program like unused histogram information, trend lines (hardly useful) or default titles.

I have configured my plotting software (matplotlib, ROOT or root2matplotlib) to do most of this right by default. Before I was using gnuplot which needed extra care here.

$\endgroup$
7
$\begingroup$

If plotting in color, consider that colorblind people may have trouble distinguishing elements by color alone. So:

  • Use line styles to distinguish lines.
  • Use extra weight in elements, make linewidth at least 2 pt, etc.
  • Use different markers as well as colors to distinguish points.
  • Use labels and annotations, referring to position and style also.
  • When referring to plot elements in text, describe them by color, relative position and style: "the red, upper, dash-dot curve"
  • Use a colorblind friendly palette. See this, this. I have a simple python implementation of the palette in the last reference at code.google.com, look for python-cudtools
$\endgroup$
1
  • $\begingroup$ Also consider the fact that someone might have to print it out on a greyscale printer. I've done this before - I used ggplot2 default colours (which look great on a screen) for an assignment, which I then printed out in black and white, and half of the colours couldn't be distinguished from the others! *blush* $\endgroup$
    – naught101
    Apr 20, 2012 at 1:34
6
$\begingroup$

Take a look at the R graphics library, ggplot2. Details are at the web page http://had.co.nz/ggplot2/ This package generates very good default plots, that follow the Tufte principles, Cleveland's guidelines and Ihaka's color package.

$\endgroup$
6
$\begingroup$

Here are my guidelines, based on the most common errors I see (in addition to all the other good points mentioned)

  • Use scatter graphs, not line plots, if element order is not relevant.
  • When preparing plots that are meant to be compared, use the same scale factor for all of them.
  • Even better - find a way to combine the data in a single graph (eg: boxplots are a better than several histograms to compare a large number of distributions).
  • Do not forget to specify units
  • Use a legend only if you must - it's generally clearer to label curves directly.
  • If you must use a legend, move it inside the plot, in a blank area.
  • For line graphs, aim for an aspect ratio which yields lines that are roughly at 45o with the page.
$\endgroup$
1
  • $\begingroup$ "boxplots are a better than several histograms to compare a large number of distributions" - this is only true if your data is unimodal, and doesn't have kurtosis or some other features that can't be captured by boxplots.. $\endgroup$
    – naught101
    Sep 19, 2016 at 0:42
4
$\begingroup$

These are wonderful suggestions. We have assembled a lot of materials here. A group of statisticians in the pharma industry, academia, and FDA have also creating a resource that are useful for clinical trials and related research here$^\dagger.$

My personal favorite graphics book is Elements of Graphing Data by William Cleveland.

In terms of software, in my opinion it is hard to beat R's ggplot2 and plotly. Stata also supports some excellent graphics.


$\dagger$ The site is unfortunately temporarily down.

$\endgroup$
3
$\begingroup$

It also depends on where you wan't to publish your plots. You'll save yourself a lot of trouble by consulting the guide for authors before making any plots for a journal.

Also save the plots in a format that is easy to modify or save the code you have used to create them. Chances are that you need to make corrections.

$\endgroup$
3
$\begingroup$

Don't use dynamite plots: http://pablomarin-garcia.blogspot.com/2010/02/why-dynamite-plots-are-bad.html, use violin plots or similar (boxplots family)

$\endgroup$
3
$\begingroup$

One thing that I seem to remember Tufte mentioning, that isn't in the other answers is mapping - that is, make position, direction, size, etc. on your graph represent reality. What is up on the graph should be up in the real world. What is big should be big (keeping in mind that areas should represent areas, and volumes volumes. Never try to represent a scalar value by an area, it's highly ambiguous!). This also applies to colours, shapes, etc, if they are relevant.

An interesting example is the "skirt series" graph here: http://a-little-book-of-r-for-time-series.readthedocs.org/en/latest/src/timeseries.html. While technically it's correct, and a "taller" skirt length occupies a higher position on the graph, it's actually quite confusing, because skirt length starts from the top, and goes down (unlike humans, or trees, where we measure the height from the ground). So increased skirt length actually represents a lower value:

    skirts <- scan("http://robjhyndman.com/tsdldata/roberts/skirts.dat",skip=5)
    skirtsseries <- ts(skirts, start=c(1866))
    plot.ts(skirtsseries, ylim=c(max(skirts), min(skirts)))

enter image description here

There are, as always, difficulties. For example, we generally consider time to move forward, and in the west, at least, we read left to right, so our time-series graphs also usually flow left to right as time increases. So what happens if you want to represent something that's best represented laterally (e.g. east-west measurements of something), over time? In that case, you have to compromise, and either portray time a moving up or down (which one depends again on cultural perceptions, I guess), or choose to map your lateral variable to up/down on your graph.

$\endgroup$
3
  • 1
    $\begingroup$ An example of the trade off for time/space is in the book, Making Maps (critical discussion and examples given here. $\endgroup$
    – Andy W
    Apr 20, 2012 at 3:41
  • $\begingroup$ Nice (horrible) example! Maps bring up another, more difficult trade off: trying to represent 2 dimensions+time on a two dimensional page (e.g. maps of continental drift). Pretty difficult. But I guess that's what animations are for :) $\endgroup$
    – naught101
    Apr 20, 2012 at 4:05
  • 1
    $\begingroup$ Your telling example allows mention of two extra points that often arise. 1. With a time axis, a title or label like "TIme" is usually redundant. 2. Titles or labels like "skirtseries" can always be improved with a terse but informative explanation, including units of measurement when appropriate. $\endgroup$
    – Nick Cox
    Sep 17, 2016 at 13:55
2
$\begingroup$

I would add that the choice of plot should reflect the type of statistical test used to analyse the data. In other words, whatever characteristics of the data were used for analysis should be shown visually - so you would show means and standard errors if you used a t-test but boxplots if you used a Mann-Whitney test.

$\endgroup$
2
$\begingroup$

The other answers are too formulaic to be convincing, so let me give a more general answer. I've struggled with this question for a while. I offer this process:

  1. Know your message
  2. Know your audience
  3. Know your constraints
  4. Tailor your message to your audience given your constraints

I am skeptical of blanket claims such as "keep it simple" -- what does that mean? Well, it depends on the audience. Some audiences will eat up the Tufte style. But some audiences appreciate a little chart junk now and then. Some people are bored by scatterplots. Some people like colorful backgrounds. Is it so wrong to engage them a little bit even if you compromise "aesthetic" purity? That is up to you to decide.

Your audience's reaction will be an important piece of feedback, but not the only one. If you find a way to measure their understanding before and after your presentation, then you will start to understand the impact you've made.

The "right" answer will depend upon these sorts of questions:

  • What media will you be using?

  • Are you creating static or interactive plots?

  • Are you trying to tell a pre-defined story (exposition) or encourage experimentation (exploration)?

  • To what degree do you want the audience to draw their own conclusions?

  • To what degree to you want the audience to follow along with and be convinced by your story?

  • To what degree to you want the audience to challenge your findings?

In summary, design your materials deliberately given your message, audience, and constraints.

$\endgroup$
1
  • $\begingroup$ "Engage", or distract? Colour can be ok, but you're ultimately here about data, and the aesthetics should serve the data, and not the other way around. $\endgroup$
    – naught101
    Apr 20, 2012 at 1:31
1
$\begingroup$

It depends on the way in which the plots will be discussed.

For instance, if I'm sending out plots for a group meeting that will be done with callers from different locations, I prefer putting them together in Powerpoint as opposed to Excel, so it's easier to flip around.

For one-on-one technical calls, I'll put something in excel so that the client be able to move a plot aside, and view the raw data. Or, I can enter p-values into cells along side regression coefficients, e.g.

Keep in mind: plots are cheap, especially for a slide show, or for emailing to a group. I'd rather make 10 clear plots that we can flip through than 5 plots where I try to put distinct cohorts (e.g. "males and females") on the same graph.

$\endgroup$
0
$\begingroup$

Here are my personal best practices (subjective):

Generally important:

  • Settle for a main message and try to most easily and effectively communicate it

  • Name your plot axes appropriately, e.g., „hours“, „dollars“, „dollars per hour“

  • If the axes titles do not already make it fully clear, indicate what unit the axis is representing, e.g., „Expenditure (in percentage of total daily USD spending)“

  • If your axis scales have a zero position, include it, e.g., in a bar chart with the height representing the count of items or for monetary values

  • If you use transformed axes, clearly indicate this, e.g., for a log-scale transformation

  • Use colours to encode information (nowadays, even scientific journal usually print in colour), e.g., food price series in „orange“ and energy price series in „blue“, if you compare two time series of prices

  • Remember that colours invoke emotions, e.g., „red“ for losses and bad events, „green“ for positive things

  • People are naturally drawn to bright colours and bold things first in a graph, so encode the most important thing for your main message in the brightest colour, e.g., they will usually spot the red line first and the rest of the plot only later

  • Otherwise, we (usually) read from left to right, up to down, so place the most important things in a title or graph ideally on the left-upper side

  • Always include a legend if you use colours

  • Remember that some people are colour blind

  • Only use 3-dimensional plots if the third dimension is necessary to convey your message

  • For bar charts: if you have categorical values on the x-axis and (many) text labels describing these, simply flip your axes so the text labels are on the y-axis instead

  • Use annotations and text labels to emphasize important values

  • Most important: do not use pie charts (never ever ;)), but bar charts instead (percentage values in pie charts are hard to read for us humans)

Depending on your audience:

  • Applied: Use action titles for your main message, e.g., „Prices increased five-fold due to supply chain issues“
  • Applied: Tell a story with one or multiple plots
  • Scientific: Neutrally describe what your graph is showing (descriptive language)
  • Scientific: Leave it to the reader to assess the evidence in the graph and come to a conclusion
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.