Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.2K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Create an ErrorListPlot with y-axis in logarithmic scale

Hello!

I had problems with adding ErrorBars on a Log Scale graphic. This is the data:

data = {{1, 2}, {2, 2}, {3, 5}, {4, 9}, {5, 14}, {6, 15}, {7, 21}, {8,
    27}, {9, 35}, {10, 45}, {11, 72}, {12, 89}, {13, 110}, {14, 
   144}, {15, 207}, {16, 303}}

f = NonlinearModelFit[data, a Exp[k t], {{a, 1}, {k, 1}}, t]

predata = {{17, f[17]}, {18, f[18]}, {19, f[19]}, {20, f[20]}, {21, 
   f[21]}, {22, f[22]}, {23, f[23]}, {24, f[24]}, {25, f[25]}, {26, 
   f[26]}, {27, f[27]}, {28, f[28]}, {29, f[29]}, {30, f[30]}, {31, 
   f[31]}, {32, f[32]}}

error = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 
  150, 160}

withError = Transpose[{predata[[All, 1]], predata[[All, 2]], error}]

Needs["ErrorBarPlots`"]

f["BestFitParameters"]

And my graphics are:

Labeled[Show[ListPlot[data], 
  ErrorListPlot[withError, PlotStyle -> Red], Plot[f[t], {t, 0, 25}], 
  Frame -> True, ImageSize -> 500, 
  PlotRange -> {{0, 25}, {0, 1000}}], {"XXX", 
  "XXX", "XXX"}, {Top, Left, Bottom}]

Labeled[Show[ListLogPlot[data], LogPlot[f[t], {t, 0, 33}], Frame -> True, 
  ImageSize -> 500, 
  PlotRange -> {0, 33}], {"XXX", "XXX", "XXX"}, {Top, Left, Bottom}]

Of course ErrorListPlot[withError] doesn't work in the 2nd graphic. Do you have any ideas how this could work?

Posted 5 years ago

Hi Matteo,

In V12 you can use the built-in function Around to specify errors. The ErrorBarPlots package is not needed. e.g.

data = Table[Around[i, Sqrt[i]], {i, 2, 20}]
ListLogPlot[data]

enter image description here

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