1
$\begingroup$

In error list plot what command I will use for denoting the range of X axis?

`data = {{20, 100}, {30, 10}, {100, 1000}, {500, 1000}};
xer = {{10, 10}, {20, 300}, {50, 50}, {100, 200}};
yer = {{50, 50}, {5, 50}, {100, 500}, {300, 100}};

errorPlot[#, data, xer, yer] & /@ {ListPlot, ListLogPlot, 
                               ListLogLogPlot, ListLogLinearPlot};`

means if I want to use the range along X axis as 0 to 20 instead of 10 then what command I will use?

$\endgroup$
3
$\begingroup$

It would be good to see what definition you're using for errorPlot as I obviously cannot run your code to see what issues you're having. That being said, one way to change the default setting for the range is this:

SetOptions[ListPlot, PlotRange -> {{minX, maxX}, {minY, maxY}}];

You can do this for each of ListPlot, ListLogPlot, ListLogLogPlot, and ListLogLinearPlot. This isn't the cleanest way as it changes the default until you start a new Notebook/Kernel, but it works if you really don't want to use the standard method of calling ListPlot and friends, which would be:

ListPlot[
    data,
    PlotRange -> {{minX, maxX}, {minY, maxY}}]

In order to get error bars on a ListPlot, we can use the ErrorBarPlots package. The ErrorListPlot function is expecting input in the form of:

{
 {{x1, y1}, ErrorBar[{-x1error, +x1error}, {-y1error, +y1 error}]},
 {{x2, y2}, ErrorBar[{-x2error, +x2error}, {-y2error, +y2error}]},
 ...
}

This is what my Table for errorData is for. It takes your variables, rearranges them into the format expected by ErrorListPlot, and makes sure the first number in each error bar is negative. We can call the following code:

Needs["ErrorBarPlots`"]
data = {{20, 100}, {30, 10}, {100, 1000}, {500, 1000}};
xer = {{10, 10}, {20, 300}, {50, 50}, {100, 200}};
yer = {{50, 50}, {5, 50}, {100, 500}, {300, 100}};

errorData = Table[{data[[i]], ErrorBar[xer[[i]] * {-1, 1}, yer[[i]] * {-1, 1}]}, {i, Length[data]}]

ErrorListPlot[
    errorData,
    PlotRange -> {{0, 710}, {0, 1500}}]

This should get us a plot that looks like this:

ListPlot of OP's data plus x and y errors.

Unfortunately, the error bar plotting package in Mathematica is not especially robust and there are no equivalents for Log, LogLinear, and LogLog Plots. However, the following post has some great workarounds so I won't bother restating them here:

Plotting Error Bars on a Log Scale

$\endgroup$
  • $\begingroup$ It is helpful for me. thank u $\endgroup$ – Priti Nayek Nov 30 '18 at 11:42
-1
$\begingroup$

http://library.wolfram.com/infocenter/MathSource/6747/ErrorBarLogPlots.zip?file_id=6147

  • Extract all files
  • Run nb file
  • Type the package name

(<< ErrorBarLogPlots’) and code required(ErrorListLogPlot[.....] in one cell!

Image1

$\endgroup$

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.