Sie sind hier: Startseite / Services / Data Analysis and Visualization / Visualization / Software / NCL / examples / source_code / DKRZ NCL color map example - use new resources
Info
Alle Inhalte des Nutzerportal sind nur auf Englisch verfügbar.

DKRZ NCL color map example - use new resources

Since NCL version 6.1.0 a few new resources to set color maps have been added - cnFillPalette, vcLevelPalette, and stLevelPalette. This example shows how to create a panel plot of two contour plot s which are using two different color maps in the same frame. Notice that the color map is set in the resource list and not with a function call of gsn_define_colormap like in older NCL scripts.

Example script:

;-----------------------------------------------------------------------------------
; DKRZ NCL Example:     color_use_cnFillPalette_to_set_colormap.ncl
;
; Description:          Demonstrate the use of cnFillPalette to set the color map
;                       for a plot which can be different for each plot in the
;                       same frame.
;
;                       cnFillPalette   colormap to used for a filled contour plot
;                       vcLevelPalette  colormap to use in a filled vector plot
;                       stLevelPalette  colormap to use in a filled streamlines plot
;
; 12.03.18  kmf
;-----------------------------------------------------------------------------------
begin
  f   = addfile("$HOME/NCL/NUG/Version_1.0/data/rectilinear_grid_2D.nc","r")
  var = f->tsurf(0,:,:)

;-- open workstation (frame)
  wks = gsn_open_wks("png","plot_color_use_cnFillPalette_to_set_colormap")

;-- set common resources
  res                       =  True
  res@gsnDraw               =  False
  res@gsnFrame              =  False
  res@gsnMaximize           =  True

  res@cnFillOn              =  True                 ;-- turn on contour fill
  res@cnLinesOn             =  False                ;-- turn off contour lines
  res@cnLineLabelsOn        =  False                ;-- turn off line labels
  res@cnLevelSelectionMode  = "ManualLevels"        ;-- set contour levels manually
  res@cnMinLevelValF        =  250.                 ;-- minimum contour level
  res@cnMaxLevelValF        =  310.                 ;-- maximum contour level
  res@cnLevelSpacingF       =    1                  ;-- contour level spacing
                  
  res@lbLabelStride         =  4                  
  res@lbBoxMinorExtentF     =  0.15                 ;-- decrease the height of the labelbar

  res@tiMainFontHeightF     =  0.02

;-- draw the first plot in memory
  res@tiMainString          = "NCL_default color map used with cnFillPalette" ;-- title string

  res@cnFillPalette         = "NCL_default"         ;-- NCL's default color map

  plot1 = gsn_csm_contour_map(wks, var, res)

;-- draw the second plot in memory
  res@tiMainString          = "NCV_blu_red color map used with cnFillPalette" ;-- title string

  res@cnFillPalette         = "NCV_blu_red"         ;-- blue to red color map

  plot2 = gsn_csm_contour_map(wks, var, res)

;-- generate the panel and advance the frame
  gsn_panel(wks,(/plot1,plot2/),(/2,1/),True)

end

Artikelaktionen