爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6728|回复: 1

[作图] ncl小白求助

[复制链接]
发表于 2015-12-3 21:47:31 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 glozs 于 2015-12-4 11:30 编辑


在做正负电荷量的图但是每次调试都感觉不尽如人意,因为每次图显示的电荷量大小差距比较大,再加上还有正负之分,图很难调。刚刚做出来一张图还算凑合(图1),但是有几个问题,想请教大神!

1.我想把零值设为白色,然后两边正电荷为暖色调,负电荷为冷色调,这样区分比较明显

2.由于有些图可能不存在正电荷(或负电荷),标签条(label bar)不会对着固定的颜色,出现图2的情况,冷色调的颜色对应的是正电荷
      注:图1是我设置了显示的最大、最小值,图2则没有设置      最好能做出例如图3的效果,每块标签色块对应一个具体的值
      求大神指导怎样做才能调出来比较完美的图!还有我的(图1)源代码如下


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

begin
;---Read data
  a = addfile("KWRAI.1.SG410.006.cdf","r")
  x = a->QIELECT

;---Open workstation
  wks = gsn_open_wks("x11","contour")   ; "ps", "pdf", "png"

;---Set some resources
  res                   = True

  res@gsnMaximize       = True     ; maximize plot in frame

;---These are sample resources you might want to set
  res@cnFillOn          = True     ; turn on contour fill
  res@cnFillPalette     = "ncl_default"   ; define color map for contours

  res@cnLinesOn         = False    ; turn off contour lines
  res@cnLineLabelsOn    = False    ; turn off line labels
  res@lbBoxLinesOn      = False     
;  res@gsnSpreadColors   = True

;---Uncomment if you want to change the contour levels
; mnmxint = nice_mnmxintvl( min(x), max(x), 18, False)
  res@cnLevelSelectionMode = "ManualLevels"
  res@cnMinLevelValF       = -2*10^-10
  res@cnMaxLevelValF       = 2*10^-10
  res@cnLevelSpacingF      = 0.4*10^-11

  res@tiMainString      = "This is a main title"

  contour = gsn_csm_contour(wks,x(:,100,:),res)
end

图1

图1

图2

图2

图3

图3
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-12-4 20:38:54 | 显示全部楼层

好吧,没人解答,我就自问自答吧,主要问题已基本解决,但是图例的数字没有显示全,求大神解答!

一下照例是代码:

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

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"


begin

;---Read data

  a = addfile("/home/glozs/gwq/KWRAI.1.SG410.006.cdf","r")

  x = a->QIELECT*10^9

  y = a->QRELECT*10^9

  z = a->QGELECT*10^9

  i = a->QCELECT*10^9

  j = a->QSELECT*10^9


;---Open workstation

  wks = gsn_open_wks("png","contour1")   ; "ps", "pdf", "png"


;---Set some resources

  res                   = True


  res@gsnMaximize       = True     ; maximize plot in frame


;---These are sample resources you might want to set

  res@cnFillOn          = True     ; turn on contour fill

  res@cnFillPalette     = "nrl_sirkes"   ;nrl_sirkes define color map for contours


  res@cnLinesOn         = False    ; turn off contour lines

  res@cnLineLabelsOn    = False    ; turn off line labels

  res@lbBoxLinesOn      = False

  res@lbOrientation     = "Vertical"     

  res@cnConstFLabelFontAspectF="1.0"

;  res@gsnSpreadColors   = True


;---Uncomment if you want to change the contour levels

;  mnmxint = nice_mnmxintvl( min(x), max(x), 18, True)

  res@cnLevelSelectionMode = "ExplicitLevels"

; res@cnMinLevelValF       = -1

; res@cnMaxLevelValF       = 1

; res@cnLevelSpacingF      = 0.01

  res@cnLevels             =(/-20.0,-10.0,-3.5,-3.0,-2.5,-2.0,-1.5\

                             ,-1.0,-0.5,-0.1,0.1,0.5,1.0,1.5\

                             ,2.0,2.5,3.0,3.5,10.0,20.0/)


  res@tiMainString      = "This is a main title"


  contour = gsn_csm_contour(wks,x(:,100,:)+y(:,100,:)+z(:,100,:)+i(:,100,:)+j(:,100,:),res)


end

contour1.png
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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