爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 7410|回复: 5

[作图] 一个小问题

[复制链接]
发表于 2015-7-30 09:29:54 | 显示全部楼层 |阅读模式

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

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

x
今天画图碰到一个小问题。坐标轴上刻度太少,我想标得精细一点,网上也没有介绍如何改变坐标轴样式、信息的帖子。试了几次改CoordArrTable (ct) Resources 却总是报错,有没有做过这方面修改与尝试的前辈可以指导一下。下面附上我的脚本(说是ncl脚本实际为了方便阅读里面是txt格式,如果要直接运行脚本好像要在linux下稍微处理下),图坐标刻度只有Y轴上间隔20的两个大刻度有数据显示,X轴上只有间隔为10的三个大刻度有数据显示。主要要解决的问题是:我想让它标注的刻度多一点。如果有大神能讲解下ncl是如何产生这样一个坐标轴过程(刻度精度,大小刻度,刻度标注)的话就太好了。

图片

图片

script_1.ncl

6.94 KB, 下载次数: 4, 下载积分: 金钱 -5

脚本

密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-7-30 09:30:30 | 显示全部楼层
脸都绿了。怎么默认要扣钱啊,怎么把扣钱的选项去掉。。。
密码修改失败请联系微信:mofangbao
发表于 2015-7-30 09:36:04 | 显示全部楼层
密码修改失败请联系微信:mofangbao
0
早起挑战累计收入
发表于 2015-7-30 12:50:50 | 显示全部楼层
asquidzair 发表于 2015-7-30 09:30
脸都绿了。怎么默认要扣钱啊,怎么把扣钱的选项去掉。。。

直接贴不就行了
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-7-30 14:24:40 | 显示全部楼层
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

function attach_labelbar(wks,map,arr[*]:numeric,colors[*])
local lbres, vph, vpw, nboxes
begin
  getvalues map
    "vpHeightF" : vph
    "vpWidthF"  : vpw
  end getvalues

  nboxes = dimsizes(colors)
   
  lbres                    = True          ; labelbar only resources
  lbres@lbAutoManage       = False          ; Necessary to control sizes
  lbres@lbFillColors       = colors
  lbres@vpWidthF           = 0.7 * vpw     ; labelbar width
  lbres@vpHeightF          = 0.2 * vph     ; labelbar height
  lbres@lbMonoFillPattern  = True          ; Solid fill pattern
  lbres@lbLabelFontHeightF = 0.01          ; font height. default is small
  lbres@lbOrientation      = "horizontal"
  lbres@lbPerimOn          = False
  lbres@lbLabelAlignment   = "InteriorEdges"
  lbid = gsn_create_labelbar(wks,nboxes,""+toint(arr),lbres)

  amres                  = True
  amres@amJust           = "TopCenter"
  amres@amParallelPosF   =  0.0    ; Center
  amres@amOrthogonalPosF =  0.6    ; Bottom
  annoid = gsn_add_annotation(map,lbid,amres)
  return(annoid)
end


begin
nrow = numAsciiRow("mp2China_100.txt")
ncol = numAsciiCol("mp2China_100.txt")
a = asciiread("mp2China_100.txt",(/nrow,ncol/),"float")   
lat=a(:,0)
lon=a(:,1)  
R=a(:,2)

  arr = (/50,100,150,200,250,300/)    ; bin settings (bin0 = < 0.,
                                         ; bin1 = 0.:4.999, etc.)
  colors = (/10,94,84,74,66,56,30/)
  labels = new(dimsizes(arr)+1,string)  ; Labels for legend.

  do i = 0, num_distinct_markers-1
    if (i.eq.0) then
      indexes = ind(R.lt.arr(0))
      labels(i) = "x < " + arr(0)
    end if
    if (i.eq.num_distinct_markers-1) then
      indexes = ind(R.ge.max(arr))
      labels(i) = "x >= " + max(arr)
    end if
    if (i.gt.0.and.i.lt.num_distinct_markers-1) then      
      indexes = ind(R.ge.arr(i-1).and.R.lt.arr(i))
      labels(i) = arr(i-1) + " <= x < " + arr(i)
    end if

    if (.not.any(ismissing(indexes))) then
      npts_range = dimsizes(indexes)   ; # of points in this range.
      lat_new(i,0:npts_range-1) = lat(indexes)
      lon_new(i,0:npts_range-1) = lon(indexes)
    end if
    delete(indexes)            ; Necessary b/c "indexes" may be a different
                               ; size next time.
  end do

  wks = gsn_open_wks("png","polyg")     ; Open a workstation and
  gsn_define_colormap(wks,"WhViBlGrYeOrRe")      ; define a different colormap.
  nc1 = NhlNewColor(wks,.8,.8,.8)        
  mpres              = True
  mpres@gsnMaximize  = True             ; Maximize plot in frame.
  mpres@gsnFrame     = False            ; Don't advance the frame

  mpres@mpOutlineOn   = True  
  mpres@mpFillOn      = False  
  mpres@mpDataBaseVersion = "MediumRes"  
  mpres@mpDataSetName="Earth..4"  
  mpres@mpOutlineSpecifiers=(/"China","Taiwan"/)  ;
  mpres@mpProvincialLineColor="black"   
  mpres@mpProvincialLineThicknessF =2   
  mpres@mpMinLatF    = min(lat) - 5.
  mpres@mpMaxLatF    = max(lat) + 5.
  mpres@mpMinLonF    = min(lon) - 5.
  mpres@mpMaxLonF    = max(lon) + 5.

  mpres@mpFillColors = (/-1,-1,nc1,-1/)    ;assign light gray to land masses

map = gsn_csm_map(wks,mpres)

  gsres               = True
  gsres@gsMarkerIndex = 16          ; Use filled dots for markers.

  txres               = True
  txres@txFontHeightF = 0.015

  do i = 0, num_distinct_markers-1
    if (.not.ismissing(lat_new(i,0)))
      gsres@gsMarkerColor      = colors(i)
      gsres@gsMarkerThicknessF = 0.7*(i+1)
      gsn_polymarker(wks,map,lon_new(i,:),lat_new(i,:),gsres)

    end if
  end do
  lbid = attach_labelbar(wks,map,arr,colors)   ; Attach a labelbar
  draw(map)     ; Drawing the map will draw everything
  frame(wks)    ; Advance the frame.
end     

附件不要下载,脚本直接贴上来啦~
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-7-30 14:32:25 | 显示全部楼层
longlivehj 发表于 2015-7-30 09:36
http://www.ncl.ucar.edu/Applications/tickmarks.shtml
http://www.ncl.ucar.edu/Document/Graphics/Reso ...

原来官网例程上都有。汗颜。。。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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