# Plotting ListStepPlot with error bar

I would like to plot ListStepPlot with error bar.

here the whole case : I am starting with data table {x1,x2,x3,....xn}. I need to integrate it "by part" (summing the n first value, then the n following etc.) and then plotting the result of the integrals in the form of a ListStepPlot so no problem there. But I want error bars on the step.

Is there a simple way to do that ? ( to be sure : my question is only about display, it is not the maths behind the error bar).

(I can using BarChart but bars are separated so it is not exactly what I need or ErrorListPlot with zero degree interpolation but the dots and error bars are not at the center of the step but on the edges so it does not look so good)

Thanks for you help !

• Can you add an example of what you currently have (as copyable code) to the question? (ideally with a mock-up of what you would like it to look in the end) - That would make it significantly easier to help you. Sep 23, 2018 at 12:33
• What about ErrorBar, see reference.wolfram.com/language/ErrorBarPlots/ref/ErrorBar.html? Sep 23, 2018 at 14:31

Update: In versions 12.0+ you do not need the "ErrorBarPlots" package. You can use Around to construct a new data set that can be used directly with ListStepPlot :

data2 = {#, Around[##2]} & @@@ data;

ListStepPlot[data2, Center,
MeshStyle -> Directive[Red, PointSize[Large]],
Mesh -> {data2[[All, 1]]},
ImageSize -> Large] You can combine ListStepPlot and ErrorListPlot as follows (using data from Okkes Dulgerci's answer):

Needs["ErrorBarPlots"]
lsp = ListStepPlot[data[[All, {1, 2}]], Center];
elp = ErrorListPlot[data, PlotRangePadding -> Scaled[.05], PlotRangeClipping -> False,
PlotStyle -> Directive[PointSize[Large], Red, LineColor -> Purple],
Prolog -> lsp[]] /. {p_Point, x__} :> {x, p} Alternatively, you can modify the input data and use ErrorListPlot with a combination of options InterpolationOrder, Mesh and ErrorBarFunction:

ErrorListPlot[Join[{-.5, 0, 0} + # & /@ data, {{.5, 0} + data[[-1, ;; 2]]}],
Joined -> True, InterpolationOrder -> 0, Mesh -> {data[[All, 1]]},
MeshStyle -> Directive[PointSize[Large], Red],
ErrorBarFunction -> ({Purple, ErrorBarPlotsPrivateebarfun[{.5, 0} + #, ##2]} &)] data = {{1, 0.012263719, 0.002}, {2, 0.007675481, 0.002}, {3,
0.008038809, 0.002}, {4, 0.008608707, 0.002}, {5, 0.010805872,
0.002}, {6, 0.008832903, 0.002}, {7, 0.009263129, 0.002}, {8,
0.011290667, 0.002}, {9, 0.014344114, 0.002}, {10, 0.025720622,
0.002}, {11, 0.028876792, 0.002}, {12, 0.035088327, 0.002}};
dist = 0.1; thicness = 0.003;
p = Graphics[{{Black, Thickness[thicness],
Line[{{#[], #[] - #[]}, {#[], #[] + #[]}}],
Line[{{#[] - dist, #[] - #[]}, {#[] +
dist, #[] - #[]}}],
Line[{{#[] - dist, #[] + #[]}, {#[] +
dist, #[] + #[]}}]} & /@ data}, PlotRange -> All];

Show[{DensityPlot[, {x, 0.5, 12.5}, {y, 0, 0.04},
AspectRatio -> 1/GoldenRatio], p,
ListStepPlot[data[[All, {1, 2}]], Center],
ListPlot[data[[All, {1, 2}]],
PlotStyle -> {AbsolutePointSize@6, Red}]}] • Exactly what i want. Thank you !I am just a bit surprise there is not a more advance dedicated error bar tool ! Sep 23, 2018 at 13:41
• @Dalnor There is - see another answer Sep 24, 2018 at 3:51