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

DKRZ NCL xy-plot with multiple lines and y-axis

The script shows how to plot two different variables in one plot.

Example script:

;-----------------------------------------------------------------
;  DKRZ - NCL Example:   NCL_xy_multiple_lines_axis.ncl
;
; - read two variables
; - use two resource objects
; - change line color
; - change line thickness
; - change line dash pattern
; - set y-axis titles
; - use gsn_csm_xy2 function
; ; 30.10.14 kmf ;----------------------------------------------------------------- begin diri = "./" ;-- directory where to find the data fili = "rectilinear_grid_3D_OM.nc" ;-- file name f = addfile(diri+fili,"r") ;-- open file t = f->t(0,0,:,{10}) ;-- read variable t; 1st timestep, 1st level, all latitudes, longitude near to 10 degrees slp = f->slp(0,:,{10}) ;-- read variable slp; 1st timestep, all latitudes, longitude near to 10 degrees x = f->lat ;-- x-axis values ;-- open a workstation wks_type = "png" ;-- graphics output type wks_type@wkWidth = 1024 ;-- graphics output width in pixels wks_type@wkHeight = 1024 ;-- graphics output height in pixels wks = gsn_open_wks(wks_type, "plot_xy_multiple_lines_axis") ;-- resources for variable t left y-axis resT = True ;-- resource object 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 slp right y-axis resSLP = True ;-- resource object 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