爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7526|回复: 0

[作图] 散点图+中国底图1

[复制链接]

新浪微博达人勋

发表于 2018-8-14 17:40:41 | 显示全部楼层 |阅读模式

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

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

x
四个不同的站点分类,加有中国省会的底图。代码和图形效果如下:

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/cnmap/cnmap.ncl"

;************************************************
begin
;************************************************
; Generate some random data
;************************************************
  h        = asciiread("/home/scatter/haidao.txt", (/361,2/), "float")
  f        = asciiread("/home/scatter/fubiao.txt", (/41,2/), "float")
  p        = asciiread("/home/scatter/pingtai.txt", (/35,2/), "float")
  y        = asciiread("/home/scatter/yanhai.txt", (/536,2/), "float")

  lonh = h(:,0)
  lath = h(:,1)

  lonf = f(:,0)
  latf = f(:,1)

  lonp = p(:,0)
  latp = p(:,1)

  lony = y(:,0)
  laty = y(:,1)

;
; There are some stations with lat/lon values outside range, so
; set these to missing.
;

  wks   = gsn_open_wks ("pdf","/home/scatter/plot/scatter")              ; send graphics to PNG file

  res             = True                              ; plot mods desired
  res@gsnFrame    = False                             ; don't advance yet
  res@gsnDraw     = False
  res@gsnMaximize = True

  res@mpMinLatF   = 0
  res@mpMaxLatF   = 55
  res@mpMinLonF   = 70
  res@mpMaxLonF   = 140
  res@mpOutlineOn           = True
  res@mpFillOn              = False
  res@mpOutlineBoundarySets = "National"          ; 边界线设置
  res@mpDataBaseVersion     = "MediumRes"
  res@mpDataSetName         = "Earth..4"
  res@mpOutlineSpecifiers   = "China:states"
  res@pmTickMarkDisplayMode = "Always"
  res@tmXBLabelFontHeightF  = 0.017
  res@tiMainString          = "Locations of stations"

  map = gsn_csm_map(wks,res)                ; Create the map plot, don't draw

  hkres               = True
  hkres@gsMarkerIndex = 1
  hkres@gsMarkerColor = "Blue"
  gsn_polymarker(wks,map,lonh,lath,hkres)

  fkres               = True
  fkres@gsMarkerIndex = 2
  fkres@gsMarkerColor = "Black"

  gsn_polymarker(wks,map,lonf,latf,fkres)

  pkres               = True
  pkres@gsMarkerIndex = 3
  pkres@gsMarkerColor = "red"

  gsn_polymarker(wks,map,lonp,latp,pkres)

  ykres               = True
  ykres@gsMarkerIndex = 12
  ykres@gsMarkerColor = "orange"

  gsn_polymarker(wks,map,lony,laty,ykres)


  frame(wks)


; If you resize the plot, the markers will be resized accordingly.
;
  hkres@gsMarkerColor = "Blue"
  hkres@gsMarkerSizeF = 15.        ; Increase marker sizes.
  dum1 = gsn_add_polymarker(wks,map,lonh,lath,hkres)

  fkres@gsMarkerColor = "Black"
  fkres@gsMarkerSizeF = 15.      
  dum2 = gsn_add_polymarker(wks,map,lonf,latf,fkres)

  pkres@gsMarkerColor = "red"
  pkres@gsMarkerSizeF = 15.      
  dum3 = gsn_add_polymarker(wks,map,lonp,latp,pkres)

  ykres@gsMarkerColor = "orange"
  ykres@gsMarkerSizeF = 15.      
  dum4 = gsn_add_polymarker(wks,map,lony,laty,ykres)


  ; Draw some individual labelbars.
;----------------------------------------------------------------------
  lbres                    = True          ; labelbar only resources
  lbres@vpWidthF           = 0.1           ; labelbar width
  lbres@vpHeightF          = 0.1           ; labelbar height
  lbres@lbBoxMajorExtentF  = 0.15          ; puts space between color boxes
  lbres@lbMonoFillPattern  = True          ; Solid fill pattern
  lbres@lbLabelFontHeightF = 0.015         ; font height. default is small
  lbres@lbLabelJust        = "CenterLeft"  ; left justify labels
  lbres@lbPerimOn          = False

;----------------------------------------------------------------------
; Draw some markers and text.
;----------------------------------------------------------------------
  labels2  = (/"haidao","fubiao","pingtai","yanhai"/)
  colors1  = (/"Blue","Black","red","orange"/)
  markers1 = (/     1,      2,     3,      12/)
   xpos1    = (/  0.15,   0.30,  0.45,    0.60/)
   xpos2  = (/  0.18,   0.33,  0.48,    0.63/)
  ;xpos1 = (/0.05,  0.20,   0.35,   0.50/)

  mkres               = lbres         ; Marker resources
  txres               = True         ; Text resources
  txres@txFontHeightF = 0.015
  txres@txJust        = "CenterLeft"
  do i = 0,3
     mkres@gsMarkerThicknessF = 3.5
     mkres@gsMarkerSizeF      = 0.02
     mkres@gsMarkerIndex      = markers1(i)
     mkres@gsMarkerColor      = colors1(i)
     ; gsn_polymarker_ndc(wks,           xpos1(i),0.16,mkres)
     ; gsn_text_ndc      (wks,labels2(i),xpos2(i),0.16,txres)
     gsn_polymarker_ndc(wks,           xpos1(i),0.07,mkres)
     gsn_text_ndc      (wks,labels2(i),xpos2(i),0.07,txres)
  end do
  draw(map)
  frame(wks)
end



1534239636(1).png

scatter.ncl

4.6 KB, 下载次数: 2, 下载积分: 金钱 -5

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

本版积分规则

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

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

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