爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 9189|回复: 4

[作图] boxplot疑问

[复制链接]
发表于 2014-3-18 11:06:28 | 显示全部楼层 |阅读模式

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

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

x
box.png
作的一个boxplot,代码片段如下:
  res@tmXBMode = "Manual"
  res@trXMinF=-6
  res@tmXBTickStartF  = 0
  res@tmXBTickSpacingF=24
  plot=boxplot(wks,xtime,plotdata,opti,res,llres)
由于x轴用预报时效,不方便使用,想将其转换为日期,
代码片段设置为:
res@tmXBMode = "Explicit"
res@tmXBValues      = xtime(0:40:4)
res@tmXBLabels     =xtimelabel(0:40:4)
res@tmXBMinorValues=xtime

xtime(0:40:4)就是(/0,24,48,72,96,120,144,168,192,216,240/)
xtimelabel是xtime转换的日期数组。
运行时提示

boxplot: Fatal:Number of XB Labels does not match number of boxes, exiting
请画过同类图的大虾帮忙。

密码修改失败请联系微信:mofangbao
发表于 2014-3-18 15:50:53 | 显示全部楼层
boxplot这个绘图函数是开放源码的,有兴趣可以看一下。
如果tmXBMode是Explicit,那么tmXBLabels的个数必须和box的个数相等。至于你贴出来的图中为何x轴标签个数少于box个数,是因为你用Manual覆盖了boxplot程序中默认的Explicit,使程序中辛辛苦苦生成的tmXBLabels失去了作用。

不过,仍然可以考虑用下面的方式来实现你要的功能:
xtimelabel2 = new(dimsizes(xtimelabel), "string")
xtimelabel2(:) = ""
xtimelabel2(0:40:4) = xtimelabel(0:40:4)

res@tmXBMode = "Explicit"
res@tmXBValues = xtime
res@tmXBLabels = xtimelabel2

plot=boxplot(wks,xtime,plotdata,opti,res,llres)

这样做的一个副作用就是,暂时无法体现出major和minor,还需要一些美化的操作!
你试试看上面的方式行不行先!
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-3-18 22:40:16 | 显示全部楼层
佩服!!!
xtimelabel2(:) = ""
xtimelabel2(0:40:4) = xtimelabel(0:40:4)

这个方法肯定行的通。
密码修改失败请联系微信:mofangbao
发表于 2016-12-31 22:43:26 | 显示全部楼层
你好,请问你调用shea_util.ncl有这个问题吗fatal:The result of the conditional expression yields a missing value. NCL can not determine branch, see ismissing function
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 2551 in file ~/plot/shea_util.ncl

fatal:["Execute.c":8575]:Execute: Error occurred at or near line 33 in file box.ncl
密码修改失败请联系微信:mofangbao
发表于 2021-1-27 20:50:15 | 显示全部楼层
clannand 发表于 2016-12-31 22:43
你好,请问你调用shea_util.ncl有这个问题吗fatal:The result of the conditional expression yields a mis ...

我也出现这个报错,将横坐标赋值后就好了,res@tmXBValues = (/.../)
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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