1
$\begingroup$

I am trying to make a very simple BarChart with individual integer errors. It seems like no solutions online address this, but instead show how to make charts with very complex errors and data, so I am not sure how to adapt those solutions to create a very simple bar chart with errors:

BarChart[{0, 2, 1, 1, 4, 5, 1, 3, 3, 3, 5, 6, 4, 3, 2, 2, 0, 7, 4, 2, 
  3, 1, 0}, ChartStyle -> {Red}, 
 ChartLabels -> {-55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5,
    0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55}]

Errors = {0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 2, 0, 1, 1, 0, 1, 2, 1, 1, 
  1, 0, 0} 
$\endgroup$
2
$\begingroup$

Using the function errorBar from Documentation >> How to | Add Error Bars to Charts and Plots:

errorBar[type_: "Rectangle"][{{x0_, x1_}, {y0_, y1_}}, value_,  meta_] := 
 Block[{error, mags = QuantityMagnitude[value]},
  error = Flatten[QuantityMagnitude[meta]];
  error = If[error === {}, 0, Last[error]];
  {ChartElementData[type][{{x0, x1}, {y0, y1}}, mags, meta], 
  {Black, Line[{{{(x0 + x1)/2, y1 - error}, {(x0 + x1)/2, y1 + error}},
  {{1/4 (3 x0 + x1), y1 + error}, {1/4 (x0 + 3 x1), y1 + error}}, 
  {{1/4 (3 x0 + x1), y1 - error}, {1/4 (x0 + 3 x1), y1 - error}}}]}}]

with your data:

errors = {0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 2, 0, 1, 1, 0, 1, 2, 1, 1, 1, 0, 0};
data = {0, 2, 1, 1, 4, 5, 1, 3, 3, 3, 5, 6, 4, 3, 2, 2, 0, 7, 4, 2, 3, 1, 0};

BarChart[Thread[data -> errors], ChartStyle -> {Red}, 
 ChartLabels -> {-55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5,
    0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55}, 
 ChartElementFunction -> errorBar[]]

Mathematica graphics

See also: BarChart with error bars, Spacing the elements in a bar chart with error bars

$\endgroup$