请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 17270|回复: 18

[作图] 散点图+中国底图+南海小图2

[复制链接]

新浪微博达人勋

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

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

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

x
根据气象家园大神的方法,需要加载一个cnmap的库,具体可看链接:http://bbs.06climate.com/forum.php?mod=viewthread&tid=11797
这个方法画出来的图只有中国区域,需要的朋友可以借鉴下,也与上篇帖子做对比。
代码和图形如下:
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"
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/scatter1")              ; 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"

res@mpFillOn                = True
res@mpOutlineOn             = False  ; Use outlines from shapefile
res@mpDataBaseVersion       = "MediumRes"
res@mpDataSetName           = "Earth..4"
res@mpAreaMaskingOn         = True
res@mpMaskAreaSpecifiers    = (/"China","Taiwan","Disputed area between India and China","India:Arunachal Pradesh"/)
res@mpLandFillColor         = "white"
res@mpInlandWaterFillColor  = "white"
res@mpOceanFillColor        = "white"
res@mpOutlineBoundarySets   = "NoBoundaries"
;>--------------------------------------------<
; set for the plot

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

cnres           = True
cnres@china     = True       ;draw china map or not
cnres@river     = True       ;draw changjiang&huanghe or not
cnres@province  = True       ;draw province boundary or not
cnres@nanhai    = True       ;draw nanhai or not
cnres@diqu      = False       ; draw diqujie or not

chinamap = add_china_map(wks,map,cnres)

  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  = (/"hai dao","fu biao","ping tai","yan hai"/)
  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



1534240304(1).jpg

scatter1.ncl

5.61 KB, 下载次数: 23, 下载积分: 金钱 -5

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

新浪微博达人勋

发表于 2018-10-22 16:47:05 | 显示全部楼层
顶一下!!感觉很有用!!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-10-22 16:51:52 | 显示全部楼层
咩咩的羊 发表于 2018-10-22 16:47
顶一下!!感觉很有用!!

谢谢,希望可以帮到你~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-10-23 11:22:43 | 显示全部楼层
您好,我想请问一下,我的地图load加载不出来怎么办呀,我已经把cnmap文件夹移动到nclscripts下面了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-10-23 14:48:17 | 显示全部楼层
HDdd 发表于 2018-10-23 11:22
您好,我想请问一下,我的地图load加载不出来怎么办呀,我已经把cnmap文件夹移动到nclscripts下面了

好像根据安装的路径不同,加载就不同,你看看你的库都在nclscripts下么?你可以直接load cnmap所在的路径。如果你也是想只画中国的边界,有个人提供的方法不错,分享给你。如下:
res@mpOutlineOn                = True              
res@mpOutlineSpecifiers        = (/"China"/)

res@mpOutlineDrawOrder         = "PostDraw";这个是我作图需要的顺序,你可以改。
res@mpOutlineBoundarySets      = "NoBoundaries";

引自:求助中国国界线画图
http://bbs.06climate.com/forum.p ... 3&fromuid=70831
(出处: 气象家园)
这个帖子里的linluoxinxia,试出来的~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-10-23 17:02:05 | 显示全部楼层
帅蛋fly 发表于 2018-10-23 14:48
好像根据安装的路径不同,加载就不同,你看看你的库都在nclscripts下么?你可以直接load cnmap所在的路径 ...

我在nclscripts下面找到了库函数 并且只有这一个文件夹 我确定是在这里 我朋友的都行 我的就是不行
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-10-23 17:02:09 | 显示全部楼层
帅蛋fly 发表于 2018-10-23 14:48
好像根据安装的路径不同,加载就不同,你看看你的库都在nclscripts下么?你可以直接load cnmap所在的路径 ...

我在nclscripts下面找到了库函数 并且只有这一个文件夹 我确定是在这里 我朋友的都行 我的就是不行
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-10-23 17:02:13 | 显示全部楼层
帅蛋fly 发表于 2018-10-23 14:48
好像根据安装的路径不同,加载就不同,你看看你的库都在nclscripts下么?你可以直接load cnmap所在的路径 ...

我在nclscripts下面找到了库函数 并且只有这一个文件夹 我确定是在这里 我朋友的都行 我的就是不行
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-10-23 21:29:54 | 显示全部楼层
HDdd 发表于 2018-10-23 17:02
我在nclscripts下面找到了库函数 并且只有这一个文件夹 我确定是在这里 我朋友的都行 我的就是不行

你试一下放在别处,直接load,前面写他的绝对路径试试
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-10-24 09:08:08 | 显示全部楼层
帅蛋fly 发表于 2018-10-23 21:29
你试一下放在别处,直接load,前面写他的绝对路径试试

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

本版积分规则

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

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

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