I came across an example where standard deviation was being plotted on a Cartesian plot (standard 2D with X and Y axes.)

This seems like a valid thing to do but in this case the example only had a single line running across the graph to "indicate" standard deviation. This to me seems not very useful, possibly dangerous and misleading. Don't you need three lines plotted to properly visualize standard deviation on a graph? Thusly:

  1. The mean
  2. The mean plus one standard deviation value
  3. The mean minus one standard deviation value

P.S. I am a software developer working on a data visualization package so please take my use of stats terminology with a grain of salt. Any corrections and feedback will be sincerely appreciated.

Rephrasing the question:

If I had a set of five data points to plot on a cartesian plane:

X:    10    20    30    35    50
Y:    20    40    5     55    10

For this sample data set (the Y values) the mean is 20 and the stdev is ~21.036 (x values plotted along the X axis and y values plotted along the Y axis.)

What would a proper plotting of the mean and the stdev on top of the X/Y data set look like?

  • $\begingroup$ What was on the x, what was on the y, and what was the point of the graph? $\endgroup$
    – Andi F
    Aug 16, 2010 at 18:46
  • $\begingroup$ @Andy: It doesn't matter. This is a software package which customers will use to their own needs with figures that can represent literally anything. In my test case I have a set of six points of data which are all positive and sit in the upper, right cartesian quadrant. $\endgroup$
    – Paul Sasik
    Aug 16, 2010 at 18:55
  • $\begingroup$ Perhaps, the line is drawn such that it is consistent with your points 1, 2 and 3. In any case, your question is so vague that I am not sure a reasonable answer can be given. $\endgroup$
    – user28
    Aug 16, 2010 at 19:11
  • $\begingroup$ Added a rephrase of the question to hopefully clarify via an example. $\endgroup$
    – Paul Sasik
    Aug 16, 2010 at 19:37
  • 3
    $\begingroup$ No, what was on the axes definitely does matter. Based on what you've written, I can imagine two different plots: one that is illustrating change in the variability of Y as X increases (in which case a simple line might be valid), and one that's illustrating the actual relationship of X and Y, which might include the mean and and SD lines... or might not. Why 1 SD? Why not 2? We can only give plotting advice with some kind of context. If people will be plotting whatever they want, all you can do is make it as flexible as possible. $\endgroup$ Aug 16, 2010 at 19:50

2 Answers 2


Probably a line for the mean and a line for +/- twice the standard deviation. That would be the "default" plot for that.

That said, I think you may be missing the point of the plot with the single line for the standard deviation. If what you're trying to represent is change in the variability of Y over X (i.e., heteroscedasticity), then a line plotting SD over X might work. It really does depend on the data and the questions that you're trying to ask. There just isn't a set of rules that you can follow to produce good plots every time, and in general the more automated the plotting system gets, the more useless I find it.

  • $\begingroup$ Thanks. That's exactly what i'm wrestling with. I have a deprecated app from a defunct company that i'm supposed to resurrect while at the same time troubleshooting their original intent. For example, the only clue (and the basis of my question) is a check box on a graph titled "show standard dev." Now, i'm supposed to recreate the functionality. Thanks for your patience btw. Any further insight is greatly appreciated. $\endgroup$
    – Paul Sasik
    Aug 16, 2010 at 20:04
  • $\begingroup$ Wow. I don't even you that task. In that context, I think what I'd do is have use the mean line + 2 SD for continuous X, and then use bars like csgillespie's for categorical data. Not sure how you'd be able to differentiate reliably between cont. and cat., but I'm sure many of attempted that before. $\endgroup$ Aug 16, 2010 at 22:29
  • $\begingroup$ Er... don't envy, I meant. $\endgroup$ Aug 17, 2010 at 14:43

What about plotting the point with error bars, say mean +/- sd. Here's what your example data would look like:

dot-plot with error bars

Here's the R code I used to generate the plot:

df = data.frame(values=c(10, 20, 30, 35, 50, 20, 40, 5, 55, 10),
  type=rep(c("X", "Y"),  each=5))

means = tapply(df$values, df$type, mean)
sds = tapply(df$values, df$type, sd)
df_summary = data.frame(means, sds, type=c("X", "Y"))

g = ggplot(data=df_summary, aes(y=means, x=type)) +
  geom_point(data=df,aes(y=values, x=type), col=2) +
  geom_errorbar(aes(ymax = means + sd, ymin=means - sd)) +

  • $\begingroup$ I don't know... Paul provided xy coordinates but not SD for all the points. We should see a graph with 5 points with perhaps some error bars (assuming we know the SD). $\endgroup$ Aug 17, 2010 at 5:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.