meatball1982 发表于 2016-5-26 10:45:43

mathematica , matlab, python ,origin画error bar

本帖最后由 meatball1982 于 2016-5-26 11:28 编辑

有个要求,画一系列数据的error bar .
注意,每个bar的上下不一样。所以是四组数。x,y,er_up,er_low

这几种方法,python 方便一堆一堆运行。
matlab我最熟悉。
mathematica 不太友好,需要自己去设置数据格式。
origin 可能都会用到。手动快些。


dat.txt
   1.00000    0.43388    0.51496    0.00000
   2.00000    0.78183    0.19788    0.09615
   3.00000    0.97493    0.11147    0.36254
   4.00000    0.97493    0.15604    0.30205
   5.00000    0.78183    0.39840    0.15218
   6.00000    0.43388    0.78364    0.57346
   7.00000    0.00000    0.63758    0.48901
   8.00000   -0.43388    0.25938    0.10085
   9.00000   -0.78183    0.12062    0.66732
10.00000   -0.97493    0.12963    0.64401

python version:
import numpy as np
import matplotlib.pyplot as plt

fi_na="./dat.txt"

x,y,er_low,er_up=np.loadtxt(fi_na,unpack='true')
y_er=np.array();

plt.errorbar(x,y,y_er,marker='s')
plt.show()


matlab version:

clear all
clc
clf

% load data
dat=load('./dat.txt');

% data
x=dat(:,1);
y=dat(:,2);
er_bar_low=dat(:,4);
er_bar_up=dat(:,3);

% output
plot(x,y,'ro-')
hold on
errorbar(x,y,er_bar_low,er_bar_up)
mathematica version,换了组数。poi = {{1, 2}, {2, 5}, {4, 7}, {5, 4}, {6, 3}, {7, 8}};
uper = {0.4, 0.3, 0.6, 1.2, 0.5, 0.4};
dner = {0.2, 0.1, 0.1, 0.4, 2.3, 1};
dat = Table[{{poi[], poi[]},
    ErrorBar[{uper[], -dner[]}]}, {i, 1, 6}];
ErrorListPlot
originalversion
将四组数据放到worksheet 里。
选中-plot-symbol-xy error
双击所画曲线的x-bar部分。
取消x-error bar
取消Plus

双击所画曲线的y-bar部分。
取消minus


就是需要的图了。



页: [1]
查看完整版本: mathematica , matlab, python ,origin画error bar