Sie sind hier: Startseite / Services / Data Analysis and Visualization / Visualization / Software / NCL / examples / source_code / DKRZ NCL xy-plot multiple lines with two y-axis example
Info
Alle Inhalte des Nutzerportal sind nur auf Englisch verfügbar.

DKRZ NCL xy-plot multiple lines with two y-axis example

NCL script creating a xy-plot with multiple lines and two y-axis.

DKRZ NCL script:

;-----------------------------------------------------------------
; 
;  DKRZ - NCL Example:   NCL_xy_multiple_lines_axis.ncl
;
;  30.10.14  kmf
;-----------------------------------------------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

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 = gsn_open_wks("png", "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

Artikelaktionen