爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 14334|回复: 22

[作图] NCL色标放在右侧失败

[复制链接]
回帖奖励 1 金钱 回复本帖可获得 1 金钱奖励! 每人限 1 次(中奖概率 80%)

新浪微博达人勋

发表于 2016-8-24 17:39:09 | 显示全部楼层 |阅读模式

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

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

x
各位大神,我在用NCL画图的时候想把色标放在右侧,但是我参考了官网上的一些设置,类似于:res@lbOrientation         = "Vertical"等语句,但是出来的结果却是这样的,请问是问题出在哪里了?

色标靠右

色标靠右
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 19:53:02 | 显示全部楼层

回帖奖励 +1 金钱

res@pmLabelBarOrthogonalPosF = -1.25
res@lbLabelPosition="left"
写了吗?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 19:57:24 | 显示全部楼层

回帖奖励 +1 金钱

我使用:
lgOrientation="Vertical"

图例在右侧,不超出图片范围
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-24 20:39:21 | 显示全部楼层
1649518749 发表于 2016-8-24 19:53
res@pmLabelBarOrthogonalPosF = -1.25
res@lbLabelPosition="left"
写了吗?

你好,谢谢关注我的帖子,我添加了这两句之后变成了这样:
test.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-24 20:41:15 | 显示全部楼层
xhw0734 发表于 2016-8-24 19:57
我使用:
lgOrientation="Vertical"

你好,多谢关注,是这样写的吗:res@lgOrientation   = "Vertical"
我换了之后图标仍然在下面...
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 20:44:56 | 显示全部楼层
是 res@lbOrientation   = "Vertical"  不是lg  
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 20:45:57 | 显示全部楼层
本帖最后由 1649518749 于 2016-8-24 20:47 编辑

然后这个res@pmLabelBarOrthogonalPosF = -1.25 这个-1.25要慢慢调。哦我看错了,是右边 你把left改成right  ,-1.25改成0.0
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-24 20:57:53 | 显示全部楼层
1649518749 发表于 2016-8-24 20:45
然后这个res@pmLabelBarOrthogonalPosF = -1.25 这个-1.25要慢慢调。哦我看错了,是右边 你把left改成right ...

哦,我原来写的就是Ib,看到楼上写的我以为我写错了。根据我调的情况,这个mLabelBarOrthogonalPosF控制的应该是上下的位置吧,一直都在中间的。有没有调节左右的指令呢?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-24 21:10:11 | 显示全部楼层
暗藏 发表于 2016-8-24 20:57
哦,我原来写的就是Ib,看到楼上写的我以为我写错了。根据我调的情况,这个mLabelBarOrthogonalPosF控制 ...

你把脚本发来看看。我画了没问题。

pressure.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-24 21:25:30 | 显示全部楼层
1649518749 发表于 2016-8-24 21:10
你把脚本发来看看。我画了没问题。

其实我也觉得很疑惑,之前我处理一个nc数据,只写了 = “Vertical” 那一句就自动合适了,但是这次处理wrf输出数据就怎么样都不行。

脚本如下:

;   Example script to produce plots for a WRF real-data run,
;   with the ARW coordinate dynamics option.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
;
; The WRF ARW input file.  
; This needs to have a ".nc" appended, so just do it.
  a = addfile("./wrfout_d01_1999-05-09_04:00:00","r")   



; We generate plots, but what kind do we prefer?
;  type = "x11"
; type = "pdf"
type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"test3")
  gsn_define_colormap(wks,"percent_11lev")   ; overwrite the .hluresfile color map

; Set some basic resources
  res = True
  res@MainTitle = ""
  res@cnInfoLabelOn        = False      ;close label on the right

  res@NoHeaderFooter = True

res@pmLabelBarOrthogonalPosF = -1.25
res@lbLabelPosition="right"
res@lbOrientation   = "Vertical"

  mpres  = True  ; Map resources
  pltres = True ; Plot resources


  mpres@mpDataSetName="Earth..4"
  mpres@mpOutlineOn   = True
  mpres@mpDataBaseVersion = "MediumRes"
  mpres@mpOutlineSpecifiers=(/"China:states","Anhui","Jiangsu","Hubei"/)
  mpres@mpProvincialLineThicknessF = 4
  mpres@mpGeophysicalLineThicknessF = 4
  mpres@mpGridLineThicknessF = 4
  mpres@mpGeophysicalLineColor = "black"
  mpres@mpProvincialLineColor ="black"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; What times and how many time steps are in the data set?
  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;  do it = ntimes-1,ntimes-1        ; TIME LOOP
    it=ntimes-12

    print("Working on time: " + times(it) )
    res@TimeLabel = times(it)   ; Set Valid time to use on plots

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need        

  lat2d = wrf_user_getvar(a,"XLAT",it)   ; latitude
  lon2d = wrf_user_getvar(a,"XLONG",it)  ; longitude



    if(isfilevar(a,"QICE"))
      qia = wrf_user_getvar(a,"QICE",it)
      qia = qia*1000.
      qia@units = "g/kg"   
    end if

     level=14
      display_level = level + 1

   ; Plotting options for qi
     opts = res
     opts@cnLevelSelectionMode = "ExplicitLevels"
     opts@cnLevels             = (/ -0.16, -0.12, -0.08, -0.04, 0, 0.04, 0.08, \
                                     0.12, 0.16,0.2/)
      opts@cnFillOn         = True
     opts@cnInfoLabelOn        = False
     opts@cnConstFLabelOn      = False
     opts@cnFillOn             = True

;----------------------------------------------------------------------
; Plot partial domain.
;----------------------------------------------------------------------
  opts@sfXArray = lon2d
  opts@sfYArray = lat2d

;---Set special resource to indicate we are using XLAT/XLONG coordinates.
  pltres@LatLonOverlay = True

;---Zoom in on map, which we can do because we're using lat/lon coordinates.
  mpres@mpLeftCornerLatF  =  20.
  mpres@mpRightCornerLatF =  40.
  mpres@mpLeftCornerLonF  = 100.
  mpres@mpRightCornerLonF = 125.


      if (isvar("qia"))
        contour = wrf_contour(a,wks,qia(level,:,:),opts)
        plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
        delete(contour)
      end if




      delete(opts)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


end
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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