Group Abstract Group Abstract

Message Boards Message Boards

1
|
4K Views
|
3 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Use Around function for lists?

Posted 6 years ago

I have a dataset of the type below:

data = {{a1,b1,c1},{a2,b2,c2},{a3,b3,c3}}

and another set of data which corresponds to my error bars for the subsequent plot:

errors = {e1,e2,e3}

I am trying to apply the error data in order to only the a parts of the data, so I want to end up with:

data = {{a1±e1,b1,c1},{a2±e2,b2,c2},{a3±e3,b3,c3}}

I am used to using ErrorListPlot with Mathematica but am now using version 12, where it is no longer used. I think I need to use MapAt and Around, but I am struggling to make this work. Is there a simple way for me to do this?

POSTED BY: Henry Sewell
3 Replies
Posted 6 years ago

Using MapIndexed rather than Replace

data // MapIndexed[{Around[First@#1, errors[[#2]]], Sequence @@ Rest@#} &]
POSTED BY: Rohit Namjoshi
Posted 6 years ago

Perfect thank you

POSTED BY: Henry Sewell
Posted 6 years ago

Hi Henry,

How about

Transpose[{data, errors}] /. {{a_, b_, c_}, d_} :> {Around[a, d], b, c}
(* {{a1±e1,b1,c1},{a2±e2,b2,c2},{a3±e3,b3,c3}} *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard