* *update by mofangbao from http://bbs.06climate.com *if you copy this script to other place,please reserve these characters * 输出colorbar的脚本 ***********************由气象家园论坛的清风基于官方的cbarn脚本改写**************** *******************************http://bbs.06climate.com********************************* **************************转载此脚本请保留脚本中的中文信息信息************************** * The script will assume a colorbar is wanted even if there is * not room -- it will plot on the side or the bottom if there is * room in either place, otherwise it will plot along the bottom and * overlay labels there if any. This can be dealt with via * the 'set parea' command. In version 2 the default parea will * be changed, but we want to guarantee upward compatibility in * sub-releases. * * * modifications by mike fiorino 940614 * * - the extreme colors are plotted as triangles * - the colors are boxed in white * - input arguments in during a run execution: * 使用说明: * run cbarn_interp interp sf vert xmid ymid * interp -表示需要的间隔,如果值小于等于0,则不标注文字,默认为1,(your interp,<=0means do not plot color key;1 in default) * sf - 标尺的大小,值从0-1变化,全尺寸为1,以此类推,默认为1. * vert - 0表示水平,1表示垂直,未含此参数则默认选择为垂直,若垂直无法放置,则为水平 * xmid - 标尺的x中心坐标,默认自动选择 * ymid - 标尺的y中心坐标,默认自动选择 * 如果不包含任何参数,将按照上面的默认算法 * if vert,xmid,ymid are not specified, they are selected * as in the original algorithm * function colorbar (args) sf=subwrd(args,2) vert=subwrd(args,3) xmid=subwrd(args,4) ymid=subwrd(args,5) interv=subwrd(args,1) *vertical in default if(sf='');sf=1.0;endif if(interv='');interv=1;endif if(math_int(interv)<=0) interv=0 else interv=math_int(interv) endif * * Check shading information * 'query shades' shdinfo = result if (subwrd(shdinfo,1)='None') say 'Cannot plot color bar: No shading information' return endif * * Get plot size info * 'query gxinfo' rec2 = sublin(result,2) rec3 = sublin(result,3) rec4 = sublin(result,4) xsiz = subwrd(rec2,4) ysiz = subwrd(rec2,6) ylo = subwrd(rec4,4) xhi = subwrd(rec3,6) xd = xsiz - xhi ylolim=0.6*sf xdlim1=1.0*sf xdlim2=1.5*sf barsf=0.8*sf yoffset=0.2*sf stroff=0.05*sf strxsiz=0.12*sf strysiz=0.13*sf * * Decide if horizontal or vertical color bar * and set up constants. * if (yloxdlim1) vchk = 1 if(vert = 0) ; vchk = 0 ; endif else vchk = 0 if(vert = 1) ; vchk = 1 ; endif endif * * vertical bar * if (vchk = 1 ) if(xmid = '') ; xmid = xhi+xd/2 ; endif xwid = 0.2*sf ywid = 0.5*sf xl = xmid-xwid/2 xr = xl + xwid if (ywid*cnum > ysiz*barsf) ywid = ysiz*barsf/cnum endif if(ymid = '') ; ymid = ysiz/2 ; endif yb = ymid - ywid*cnum/2 'set string 1 l 5' vert = 1 else * * horizontal bar * ywid = 0.4 xwid = 0.8 if(ymid = '') ; ymid = ylo/2-ywid/2 ; endif yt = ymid + yoffset yb = ymid if(xmid = '') ; xmid = xsiz/2 ; endif if (xwid*cnum > xsiz*barsf) xwid = xsiz*barsf/cnum endif xl = xmid - xwid*cnum/2 'set string 1 tc 5' vert = 0 endif * * Plot colorbar * 'set strsiz 'strxsiz' 'strysiz num = 0 cinterv=0 while (num