爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5375|回复: 2

[其他] 小白求助~~~

[复制链接]

新浪微博达人勋

发表于 2018-8-30 18:56:14 | 显示全部楼层 |阅读模式

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

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

x
刚开始学NCL,现在相出一张多折线图,并在xy折线图中[-40,1]处添加红色星号,在[-30,1][-20两点处绘制任意蓝色折线,但是出现了报错。我把一部分代码写上来,请大家帮帮忙!谢谢了!

;add a mark in [-40,1], just regard this mark as Nanjing
;add a broken line, just regard the typhoon path as broken line
begin
  npts = 500
  x    = fspan(-100,100,npts)   ; 500 values from -100 to 100.

  x1 = -40
  y1 = 1

  x_line = (/-30,-20/)
  y_line = (/1,-1/)

  y = new((/4,500/),"float")
  y(0,:) = sin(0.0628*x)     
  y(1,:) = cos(0.0628*x)
  y(2,:) = cos(0.0628*x)*sin(0.0628*x)  
  y(3,:) = cos(0.0628*x)+sin(0.0628*x)  

  wks = gsn_open_wks("eps","xy_legend_ex")


  ;the range or X/Y aixs

  res = True
  res@trXMinF           = min(x)            
  res@trXMaxF           = max(x)
  res@trYMinF           = min(y)-0.2   ;áô3öêêμ±μÄ¿Õ°×£¬»æÖÆlegend
  res@trYMaxF           = max(y)+0.6   ;

  ;res part
  ;Line thickness, colors, dash pattern mode, labal of each line,
  ;legend mode, labels, width, height, orthogonal position, parallel position
  res@xyLineThicknesses = (/1,2,3,4/) ;ÿ¸ö¶Ôó|¸ö′Öϸ£¬èôÖ»óDò»ìõÏß¾íò»¸öÖμ£¬×¢òaes   
  res@xyLineColors = (/"black","black","black","black"/)
  res@xyDashPatterns = (/0,2,4,6/) ;appendix H.6
  res@pmLegendDisplayMode = "Always" ;ìí¼óí¼ày
  res@xyExplicitLegendLabels = (/"one","two","three","four"/);ÿìõÕÛÏßμÄÃû3Æ
  res@pmLegendWidthF = 0.2 ;í¼àyμÄ¿í¶è
  res@pmLegendHeightF = 0.1 ;í¼àyμĸ߶è
  res@pmLegendOrthogonalPosF = -1.05
  res@pmLegendParallelPosF = 0.82

  plot = gsn_csm_xy(wks,x,y,res)

  ;add marker
  mkres = True
  mkres@gsMarkerColor = "blue"
  mkres@gsMarkerIndex = 12
  mkres@gsMarkerSizeF = 0.02
  dum1 = gsn_add_polymarker(wks, plot, x, y, mkres)

  ;add line
  lnres = True
  lnres@gsLineColor = "red"
  lnres@gsLineDashPattern = 16
  lnres@gsLineThicknessF = 3.0
  dum2 = gsn_add_polyline(wks, plot, x_line, y_line, lnres)

  draw(plot)
  frame(wks)
end

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

新浪微博达人勋

发表于 2018-8-30 19:41:23 | 显示全部楼层

回帖奖励 +5 金钱

  1. dum1 = gsn_add_polymarker(wks, plot, -40, 1, mkres)   ;
复制代码
ps:
draw(plot)
frame(wks)一般不是与下面两句一起用吗?我也是NCL小白,希望能帮到你,
  1. res@gsnDraw           = False
  2. res@gsnFrame          = False
复制代码


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

新浪微博达人勋

发表于 2018-8-31 00:15:45 | 显示全部楼层
再过几天我也要学了,看着有点难啊
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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