- 积分
- 289
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-10-7
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
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
|
|