3
$\begingroup$

I have the following data:

data= {{60, 4.92444, 0.156206}, {65, 3.73818, 0.0458043}, {70, 2.19564, 
      0.0539134}, {75, 0.6554, 0.0533553}, {80, 1.0604, 0.0127809}, {85, 
      0.790124, 0.0630165}, {87, 0.594196, 0.109998}, {90, 0.0166927, 
      0.014323}, {92, 0.044787, 0.0246567}}

Where the values are {x-value,y-value,error}

Question:

How can I plot the x-values and y-values and the errors as error bars in a plot?. If I use ListPlot[data[[All, {1, 2}]]], I can only plot the x-values and y-values but I do not know how to incorporate the errors as error bars in the same plot.

$\endgroup$
3
$\begingroup$

Transform your data using Around:

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

ListPlot[data2]

enter image description here

ListPlot[data2, 
  IntervalMarkers -> "Bands", IntervalMarkersStyle -> Pink]

enter image description here

ListPlot[data2, 
  IntervalMarkersStyle -><|"FenceWidth" -> 2,"FenceStyle" -> Red |>]

enter image description here

$\endgroup$
5
  • $\begingroup$ kglr thank you! This work great ! . Can I ask you how is it possible to change the size of only the error bars from your code? $\endgroup$ – John Jun 27 '20 at 20:34
  • $\begingroup$ @John, try if IntervalMarkersStyle -> "FenceWidth" -> k (for your choice of a number k) gives what you need. $\endgroup$ – kglr Jun 27 '20 at 20:40
  • $\begingroup$ kglr thank you but if I try ListPlot[data2, IntervalMarkersStyle -> "FenceWidth" -> 800] (even putting a number like 800) does not work at all to change the size of the error bar. I am interested in the first figure you plotted but it would be great if I can also make a little bigger the error bars of even put them Bold $\endgroup$ – John Jun 27 '20 at 20:44
  • $\begingroup$ @John, try IntervalMarkersStyle -> <|"FenceWidth" -> k|> for different different values for k. $\endgroup$ – kglr Jun 27 '20 at 20:51
  • $\begingroup$ Awesome! Thanks for your help! I have accepted your great answer ! $\endgroup$ – John Jun 27 '20 at 21:01

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.