Wolfram mathematica 用函数形式绘制误差带
我有一个包含x、y和error(y)值的数据集。我在mathematica中写道:Wolfram mathematica 用函数形式绘制误差带,wolfram-mathematica,Wolfram Mathematica,我有一个包含x、y和error(y)值的数据集。我在mathematica中写道: Needs["ErrorBarPlots`"] data = {{{0, 0.10981309359605919}, ErrorBar[0.05240427422664753`]}, {{0.2145, 0.09146326059113304}, ErrorBar[0.034195343626358385`]}, {{0.4290, 0.08230438177339898}, Err
Needs["ErrorBarPlots`"]
data = {{{0, 0.10981309359605919},
ErrorBar[0.05240427422664753`]}, {{0.2145, 0.09146326059113304},
ErrorBar[0.034195343626358385`]}, {{0.4290, 0.08230438177339898},
ErrorBar[0.02533205817067696`]}, {{0.6435, 0.0768141842364532},
ErrorBar[0.020205473852635995`]}, {{0.8580, 0.07223473349753692},
ErrorBar[0.016156209168991867`]}, {{4, 0.056122650246305375},
ErrorBar[0.009288720442961331]}};
ErrorListPlot[data, Frame -> True, FrameStyle -> Directive[Black, 20],
PlotRange -> {{-0.1, 5}, {0.2, 0}}, Axes -> False,
PlotStyle -> {Directive[Red, 12], AbsolutePointSize[10],
AbsoluteThickness[3]} , LabelStyle -> Directive[Green],
BaseStyle -> {Large, FontFamily -> "Courier", FontSize -> 12}]
但我试图得到的是画一条线,得到一个阴影的误差带,连接服从函数形式的误差条,f(x)=0.05+0.02/(x^2+0.425)
。我不想显式地显示错误条,而是想显示条带。我在找这样的东西
我已经看过这个链接了
但无法解决问题。谁能帮帮我吗?谢谢 这里有一种方法,列出两个列表,一个列表显示错误的上限:
dataPLUS = {{0, 0.10981309359605919 + 0.05240427422664753`}, {0.2145,
0.09146326059113304 + 0.034195343626358385`}, {0.4290,
0.08230438177339898 + 0.02533205817067696`}, {0.6435,
0.0768141842364532 + 0.020205473852635995`}, {0.8580,
0.07223473349753692 + 0.016156209168991867`}, {4,
0.056122650246305375 + 0.009288720442961331}};
以下是较低错误范围的另一个列表:
dataMINUS = {{0, 0.10981309359605919 - 0.05240427422664753`}, {0.2145,
0.09146326059113304 - 0.034195343626358385`}, {0.4290,
0.08230438177339898 - 0.02533205817067696`}, {0.6435,
0.0768141842364532 - 0.020205473852635995`}, {0.8580,
0.07223473349753692 - 0.016156209168991867`}, {4,
0.056122650246305375 - 0.009288720442961331}};
一旦有了这两个集合,您就可以使用列表打印选项,如下所示:
ListPlot[{dataPLUS, dataMINUS}, PlotStyle -> Red, PlotRange -> All]
这将生成一个类似于
如果要加入它们,请使用ListLinePlot选项
ListLinePlot[{dataPLUS, dataMINUS}, PlotStyle -> Red,PlotRange -> All]
ListLinePlot[{dataPLUS, dataMINUS}, PlotStyle -> Red, Filling -> {1 -> {{2}, Gray}}, PlotRange -> All]
要在中间有一个阴影区域,请使用填充选项
ListLinePlot[{dataPLUS, dataMINUS}, PlotStyle -> Red,PlotRange -> All]
ListLinePlot[{dataPLUS, dataMINUS}, PlotStyle -> Red, Filling -> {1 -> {{2}, Gray}}, PlotRange -> All]
要获得平滑的图形,需要更多的数据点。希望这会有所帮助
要包括最佳拟合行,请定义一个函数并将其添加到前面的图中,如下所示:
f[x_] = 0.05 + 0.02/(x^2 + 0.425);
plot2 = Plot[f[x], {x, 0, 5}, PlotStyle -> {Red, Thick}];
plot1 = ListLinePlot[{dataPLUS, dataMINUS}, PlotStyle -> LightGray,Filling -> {1 -> {{2}, LightGray}}, PlotRange -> All];
Show[{plot1, plot2}]
这太好了,非常感谢String先生:)