DKRZ NCL xy-plot with multiple lines and y-axis#
Example script:
;-----------------------------------------------------------------
;
; DKRZ - NCL Example: NCL_xy_multiple_lines_axis.ncl
;
; 30.10.14 kmf
;-----------------------------------------------------------------
begin
;-- define file name
diri = "./"
fili = "rectilinear_grid_3D_OM.nc"
;-- open file and read variable
f = addfile(diri+fili,"r")
;-- set variable (zonal wind)
t = f->t(0,0,:,{10}) ;-- set variable t; y-axis on the left
slp = f->slp(0,:,{10}) ;-- set variable slp; y-axis on the right
x = f->lat
;-- open a workstation
wks_type = "png"
wks_type@wkWidth = 1024
wks_type@wkHeight = 1024
wks = gsn_open_wks(wks_type, "plot_xy_multiple_lines_axis")
;-- resources for variable left y-axis
resT = True
resT@xyLineThicknessF = 3.0 ;-- set line thickness
resT@xyLineColor = "red" ;-- set line color
resT@xyDashPatterns = 0 ;-- solid line
resT@tiYAxisString = t@long_name +" "+"[solid]" ;-- axis string
;-- resources for variable right y-axis
resSLP = True
resSLP@xyLineThicknessF = 3.0 ;-- set line thickness
resSLP@xyLineColor = "blue" ;-- set line color
resSLP@xyDashPatterns = 1 ;-- dashed line
resSLP@tiYAxisString = slp@long_name +" "+"[dash]" ;-- axis string
resSLP@tiMainString = "Temperature and Sea Level Pressure at lon=10 deg" ;-- draw title
;-- create the plot
plot = gsn_csm_xy2(wks, x, t, slp, resT, resSLP)
end
Result: