Is it okay to add error bars into a histogram plot?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
10 replies · 3K views
tryingtolearn1
Messages
58
Reaction score
5
Homework Statement
Is it okay to include error bars in a histogram plot?
Relevant Equations
None
I made a histogram based off a dataset and I calculated the uncertainty of the measurements and I included the error bars into my histogram. Is that okay? I am asking because I never seen error bars included with a histogram. I have included an image of my histogram below:
 

Attachments

  • 550mV.png
    550mV.png
    12.4 KB · Views: 237
Physics news on Phys.org
Hi,

I would say yes.
When I look at the picture a few other things strike me:
The red dots have no function (and are not in the legend)
Names in legend are rather meaningless ('histogram'?, 'best fit curve'?)
Y axis is anything but Events/Bins
The title discriminator threshold doesn't seem to apply to the picture but to be some experimental setting
##\chi^2_r =1.0## always makes me suspicious (not paranoid, just experienced... :wink: )

##\ ##
 
  • Like
Likes   Reactions: DaveE
Unless you are specifically required to do otherwise, you might consider not using a histogram at all - just the data-points/error-bars plus the best-fit curve.

If the graph is known to represent some sort of exponential process, a more useful approach might be to make a graph with ln (natural logarithm) of the 'y-axis' values. This should give a straight line where the gradient will have a physical meaning. (If you plot such a graph, then using a histogram would be inappropriate IMO.)
 
  • Like
Likes   Reactions: tryingtolearn1 and DaveE
I agree with @Steve4Physics. A good graph should contain lots of information in a simple self-explanatory manner: making a good one requires some visual design. The histogram format adds nothing. Also the box telling us that the error bars are error bars is superfluous...
 
  • Like
Likes   Reactions: tryingtolearn1 and DaveE
Steve4Physics said:
Unless you are specifically required to do otherwise, you might consider not using a histogram at all - just the data-points/error-bars plus the best-fit curve.
In general, it is not an open choice. Histograms are normally used when there is a single undifferentiated list of numbers. There are no (x,y) pairs from which to plot a graph.
That's why I asked how the errors bars are derived. There is not usually any basis for such in a histogram.
We need need more background from @tryingtolearn1.
 
  • Like
Likes   Reactions: Steve4Physics and hutchphd
haruspex said:
Most histograms are of exactly known numbers, so no error bars.
Please describe how you arrived at these error bars.
The error bars were produced by taking the Poisson of the counts, i.e. if N are the counts the error bars was ##\sqrt{N}##.
BvU said:
Hi,

I would say yes.
When I look at the picture a few other things strike me:
The red dots have no function (and are not in the legend)
Names in legend are rather meaningless ('histogram'?, 'best fit curve'?)
Y axis is anything but Events/Bins
The title discriminator threshold doesn't seem to apply to the picture but to be some experimental setting
##\chi^2_r =1.0## always makes me suspicious (not paranoid, just experienced... :wink: )

##\ ##
Thanks I will modify my plot based off these suggestions
 
Last edited:
  • Like
Likes   Reactions: Dale
haruspex said:
In general, it is not an open choice. Histograms are normally used when there is a single undifferentiated list of numbers. There are no (x,y) pairs from which to plot a graph.
That's why I asked how the errors bars are derived. There is not usually any basis for such in a histogram.
We need need more background from @tryingtolearn1.
I was able to find a lab report similar to mine that illustrates the usage better. If you look at page 3, in this link: https://sites.fas.harvard.edu/~phys191r/References/b4/Coan2006.pdf

the plot there is very similar to mine except they didn't include the histogram.
 
tryingtolearn1 said:
I was able to find a lab report similar to mine that illustrates the usage better. If you look at page 3, in this link: https://sites.fas.harvard.edu/~phys191r/References/b4/Coan2006.pdf

the plot there is very similar to mine except they didn't include the histogram.
It states that figure 3 is a histogram - they just haven't shown the columns - and it does show error bars, apparently calculated the same way you have done.

To me, it is an unusual use of the concept of an error bar, though. There are no actual errors, these are exact counts. I can see they represent uncertainty in that if you were to rerun the experiment these are the ranges of counts you expect in each bucket. But the uncertainties in neighbouring buckets are not independent.
The uncertainty is not so much in the individual counts as in the buckets the observations should have gone in. If another run of the experiment produces a larger count in one bucket it will very likely produce lower counts in neighbouring buckets.
To look at it another way, if one bucket has a lower count than both neighbours then its error bar should extend further above its count than below that.

I feel there's a better way. I'll think about it some more.
 
  • Like
  • Informative
Likes   Reactions: Steve4Physics, hutchphd, BvU and 1 other person
Further thoughts...
I presume the aim is to estimate the Poisson parameter. If we have time samples (ti) and a supposed parameter λ then the joint pdf is ##p((t_i)|\lambda)=\Pi\lambda e^{-\lambda t_i}=(\lambda e^{-\lambda\bar t})^n##, where ##\bar t## is the average time.
Clearly this is maximised at ##\hat\lambda=\frac 1{\bar t}##. You can plot ##p((t_i)|\lambda)## against λ and compute the standard deviation for λ.
You could then return to the histogram, draw the curve through it for ##\hat\lambda##, and curves one (or two) standard deviations either side as the "error bar".
 
  • Like
Likes   Reactions: tryingtolearn1
tryingtolearn1 said:
I was able to find a lab report similar to mine that illustrates the usage better. If you look at page 3, in this link: https://sites.fas.harvard.edu/~phys191r/References/b4/Coan2006.pdf

the plot there is very similar to mine except they didn't include the histogram.
Probably down to aesthetics. Drawing a conventional histogram would produce something extremely cluttered and hard-on-the-eye, especially with error bars.

Also worth noting is that the graph in your link uses a logarithmic scale.
 
  • Like
Likes   Reactions: tryingtolearn1