0
$\begingroup$

enter image description hereI have 2 sets of data imported from excel file, Let say A = 20 21 22 ... 30A B= 0 1 2 3 ... 10 I want to plot A with a relative error of 10%

errordataA= Around[A,Scaled[.1]]

But output was "Around[A, Scaled[0.1]]" not "Around[2+-10%]".

Then I want to create a plot with B.

ListPlot[
 {A,
  B
    }
   IntervalMarkers -> "Bands",
 Sequence[PlotTheme -> "Scientific",
  PlotRangePadding -> {Automatic, Scaled[0.15]}]
 ]

Since the code can't read set A data so the graph does not show. How can I fix this one?

$\endgroup$
4
  • 1
    $\begingroup$ Around is not defined as a function in your system (it is in blue in your screenshot). Note that Around was introduced in version 12 (2019). What version are you using? $\endgroup$
    – MarcoB
    Commented Nov 29, 2020 at 23:10
  • $\begingroup$ What version of Mathematica are you using? $\endgroup$
    – m_goldberg
    Commented Nov 29, 2020 at 23:48
  • $\begingroup$ @MarcoB Now I can use "Around". Just updated to M12. Thanks all $\endgroup$ Commented Nov 30, 2020 at 21:19
  • $\begingroup$ @m_goldberg it was M10 and now I already updated it. $\endgroup$ Commented Dec 1, 2020 at 21:34

2 Answers 2

1
$\begingroup$

The Around expression you mention seems to work fine for me:

a = Around[Range[20, 30], Scaled[0.1]]

(* Out: {Around[20., 2.], Around[21., 2.1], Around[22., 2.2], 
         Around[23., 2.3], Around[24., 2.4], Around[25., 2.5], 
         Around[26., 2.6], Around[27., 2.7], 
         Around[28., 2.8], Around[29., 2.9], 
         Around[30., 3.]} *)

From there, I think you might want to plot a vs. b, i.e. the a values as ordinates and the values as abscissae. If that's what you want, then that works too, but you will want to Transpose the {b, a} set of data:

a = Around[Range[20, 30], Scaled[0.1]]
b = Range[0, 10]

ListPlot[
  Transpose@{b, a},
  IntervalMarkers -> "Bands",
  PlotTheme -> "Scientific",
  PlotRangePadding -> {Automatic, Scaled[0.15]}
]

plot with error bands

—-

An alternative interpretation after OP’s comments:

ListPlot[
  {a, b},
  IntervalMarkers -> "Bands",
  PlotTheme -> "Scientific",
  PlotRangePadding -> {Automatic, Scaled[0.15]}
]

data as two separate series

$\endgroup$
5
  • $\begingroup$ Hi, Thank you very much for your comment. I added the picture above. I have no idea why I could not get output like yours. 2ndly, I want to plot {x,A,x,B} not {A,B}. I guess I can plot it directly if I can get A in terms of the digit. $\endgroup$ Commented Nov 29, 2020 at 22:33
  • $\begingroup$ @user8357568 What do you mean by x in your example? $\endgroup$
    – MarcoB
    Commented Nov 29, 2020 at 23:11
  • $\begingroup$ X is y axis. just give some random numbers. $\endgroup$ Commented Nov 30, 2020 at 7:38
  • $\begingroup$ @user8357568 I see. I’ve added a second output. See if that’s what you meant. $\endgroup$
    – MarcoB
    Commented Nov 30, 2020 at 14:19
  • $\begingroup$ @MacroB Regarding your advice, it works great. I have one more question. How can I plot with Transpose[x,a], Transpose [x,b] and a is a = Around[Range[20, 30], Scaled[0.1]] b is b = Range[0, 10] x = Range[0,1] $\endgroup$ Commented Dec 1, 2020 at 21:30
1
$\begingroup$

For versions prior to v12

Clear["Global`*"]

Needs["ErrorBarPlots`"] // Quiet

a = {1, 0.1} # & /@ Range[20, 30];

b = Range[0, 10];

ErrorListPlot[{a, b},
 PlotRangePadding -> {Automatic, Scaled[0.1]},
 PlotLegends -> {"a", "b"},
 PlotTheme -> "Scientific"]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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