爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8416|回复: 2

[作图] 请问如何用NCL在柱状图上画误差棒

[复制链接]

新浪微博达人勋

发表于 2017-11-30 23:53:58 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
图片中是MeteoInfoLab脚本示例:误差棒 - errorbar,请问如何用NCL在柱状图上画误差棒
误差棒.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-11-16 19:51:51 | 显示全部楼层
请问楼主的问题解决了吗,我也想画这样的图,找不到例子
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-4-6 17:23:17 | 显示全部楼层
这里有一个折线图误差线的画法,不知道有没有帮助
xy_13.ncl:使用gsn_add_polyline和gsn_add_polymarker添加误差线。
;*************************************************
; xy_13.ncl
;
; Concepts illustrated:
;   - Drawing error bars on an XY plot
;
;************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; read in netCDF file
;************************************************
  a = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r")
  u = a->V(0,:,30)
;************************************************
; create plot
;************************************************
  wks = gsn_open_wks("png","xy")                         ; send graphics to PNG file

  res                        = True                      ; plot mods desired
  res@tiYAxisString          = u@long_name + " "+u@units ; add units title
  res@tiMainString           = "Example of error bars"   ; title
  res@gsnFrame               = False                     ; don't draw yet
  res@gsnDraw                = False                     ; don't advance frame

  plot = gsn_csm_y(wks,u,res)                            ; draw y plot
;************************************************
; add error bars
;************************************************  
  polyres                   = True                       ; marker resources
  polyres@gsMarkerIndex     = 1                          ; index for circle
  polyres@gsMarkerSizeF     = .02                        ; size
  
; gsn_add* templates are functions that we set to dummy values. Since
; we are going to draw numerous error bars, we create two arrays to
; hold the dummy values.
  error_bar = new(dimsizes(u),graphic)
  centers   = new(dimsizes(u),graphic)

; loop through the points  
  do t=0,dimsizes(u)-1
; add a polymarker as the center of the error bar located at each data
; point
    centers(t)   = gsn_add_polymarker(wks,plot,t,u(t),polyres)
; the error bar is draw in two segements, above and below the true
; value of u(t). I made up these value. You would change this to
; true error.      
    error_bar(t) = gsn_add_polyline(wks,plot,(/t,t/),(/u(t)+1.5,u(t)-1.0/),\
    polyres)
  end do
  draw(plot)
  frame(wks)
end
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表