Bo Zhang's Homepage
..The universe is unfolding as it should..

2007-10-14

IDL绘制双轴误差棒

归档于: 天文软件 @ 11:10 pm

本来对于IDL来说,误差棒的绘制是小事一桩,比如软件自带了ploterr和oploterr,天文库里也有ploterror和oploterror函数可以使用。怎奈本人的本科毕业论文涉及了大量带有双轴不对称误差的统计数据,这些现成的函数要么只能处理对称误差,要么只能给出单轴误差,因此几无用武之地,只得另寻他路。

参考闫殿武书中绘制单轴不对称误差棒的例子,自己弄了个绘制双轴不对称误差棒的函数,给出双轴误差的上下限和数据值即可使用。其实这里我是大大地偷了个懒(也是因为当时赶论文时间紧张),鉴于相当一部分文献(如Amati et al. 2002,Panaitescu 2006,Ghirlanda et al. 2007……)的插图没有画出误差棒端点的短横,该函数也就把误差棒端点的绘制省略掉了,够用就OK……

输入的数据是中值和双轴误差范围,要结合主程序使用,调用方法就不要我多说了吧。

;x: n-element array, data for x-axis;
;xlow: n-element array, lower limit for x-axis;
;xhigh: n-element array, upper limit for x-axis;
y: n-element array, data for y-axis;
ylow: n-element array, lower limit for y-axis;
yhigh: n-element array, upper limit for y-axis;

pro err_plot,x,xlow,xhigh,y,ylow,yhigh,_extra=extra_keywords

;- Check arguments
if (n_params() ne 6) then message, $
‘Usage: ERR_PLOT, X, XLOW, XHIGH, Y, YLOW, YHIGH’
if (n_elements(x) eq 0) then $
message, ‘Argument X is undefined’
if (n_elements(xlow) eq 0) then $
message, ‘Argument XLOW is undefined’
if (n_elements(xhigh) eq 0) then $
message, ‘Argument XHIGH is undefined’
if (n_elements(y) eq 0) then $
message, ‘Argument Y is undefined’
if (n_elements(ylow) eq 0) then $
message, ‘Argument YLOW is undefined’
if (n_elements(yhigh) eq 0) then $
message, ‘Argument YHIGH is undefined’

;Plot the error bars
for index = 0L, n_elements(xlow) - 1L do begin

;Plot vertical bars
xdata = [x[index], x[index]]
ydata = [ylow[index], yhigh[index]]
plots, xdata, ydata, /data, noclip=0, _extra=extar_keywords

;Plot horizontal bars
xdata = [xlow[index], xhigh[index]]
ydata = [y[index], y[index]]
plots, xdata, ydata, /data, noclip=0, _extra=extar_keywords
endfor

end

实际效果:

卖个关子,谁知道这个是什么图?

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

首页 | 天文 | 科学 | 摄影 | 模型 | CV | 版权声明 | 联系站长
京ICP备05002854号-2 Powered by WordPress Version 2.0.6
Licensed under Creative Commons Licenses

porno izle