If I have a set of data like this one saved in a txt file
0.0000000328806432649482    68   0.00000000328806432649482   1
0.0000000394567719179379    81   0.00000000328806432649482   1
0.0000000460329005709275    96   0.00000000328806432649482   1
0.0000000526090292239172    110  0.00000000328806432649482   1
0.0000000591851578769068    119  0.00000000328806432649482   1
0.0000000657612865298965    131  0.00000000328806432649482   1
.
.
.
The first two coliumns are the measurement values, the last two the errors. How can I plot it with the x and y error bars, without typing the ErrorBar[...] arround every of the last two coloumns by hand?
Answer
Needs["ErrorBarPlots`"]
values=ImportString[
 "0.0000000328806432649482    68   0.00000000328806432649482   1
  0.0000000394567719179379    81   0.00000000328806432649482   1
  0.0000000460329005709275    96   0.00000000328806432649482   1
  0.0000000526090292239172    110  0.00000000328806432649482   1
  0.0000000591851578769068    119  0.00000000328806432649482   1
  0.0000000657612865298965    131  0.00000000328806432649482   1"
 ];
ErrorListPlot[{{#1, #2}, ErrorBarPlots`ErrorBar @@ {#3, #4}} & @@@ values,
 PlotRangePadding -> {Scaled[0.15], Automatic}
]

I used ImportString because it was more expedient to copy/paste your data, but of course you can import the data directly from your file just as easily:
values = Import[pathtofile]
Comments
Post a Comment