Suppose I have a list of data I can ListPlot:

{ {x1,y1}, ... }

, and a list of y-errorbars:

{erry1, erry2, ... }

Is there a nice, high level way to make it into a list for ErrorListPlot:

{ {{x1,y1}, ErrorBar[erry1]}, ... }

It of course easy to do it through iteration in Table, however I keep reading about, how it is not the right way in Mathematica to use iterations (at least over lists).

data1 = {{x1, y1}, {x2, y2}, {x3, y3}};
data2 = {error1, error2, error3};
Transpose[{data1, ErrorBar /@ data2}]
Thread[{data1, ErrorBar /@ data2}]

{{{x1, y1}, ErrorBar[error1]}, {{x2, y2}, ErrorBar[error2]}, {{x3, y3}, ErrorBar[error3]}}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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