forked from NOAA-PSL/ncl_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanel_plot.ncl
More file actions
executable file
·74 lines (66 loc) · 2.97 KB
/
panel_plot.ncl
File metadata and controls
executable file
·74 lines (66 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;*************************************************
; panel_5.ncl
;
; Concepts illustrated:
; - Paneling three plots vertically on a page
; - Adding a common title to paneled plots
; - Adding a common labelbar to paneled plots
; - Adding figure strings to paneled plots
; - Customizing figure strings in paneled plots
; - Subsetting a color map
;************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; read in netCDF file
;************************************************
a = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r")
u = a->U(1,:,:) ; read July zonal winds
v = a->V(1,:,:)
;************************************************
; create plots
;************************************************
wks = gsn_open_wks("png","panel") ; send graphics to PNG file
cmap = read_colormap_file("gui_default")
ncmap = dimsizes(cmap(:,0))
plot = new(3,graphic) ; create a plot array
res = True
res@gsnDraw = False ; don't draw
res@gsnFrame = False ; don't advance frame
res@cnInfoLabelOn = False ; turn off cn info label
res@cnFillOn = True ; turn on color
res@cnFillPalette = cmap(:ncmap-3,:) ; skip last two colors
res@lbLabelBarOn = False ; turn off individual cb's
;
; Force both plots to have the same contour levels. This is necessary
; because the gsn_panel routine will based the labelbar on the first
; plot in the list.
;
res@cnLevelSelectionMode = "ManualLevels"
res@cnMinLevelValF = -10.
res@cnMaxLevelValF = 45.
res@cnLevelSpacingF = 5.
plot(0) = gsn_csm_contour_map(wks,u,res)
plot(1) = gsn_csm_contour_map(wks,v,res)
plot(2) = gsn_csm_contour_map(wks,u,res)
;************************************************
; create panel
;************************************************
resP = True ; modify the panel plot
resP@gsnFrame = False ; don't advance panel plot
resP@gsnPanelLabelBar = True ; add common colorbar
; resP@gsnPanelMainString = "A common title" ; new way of setting main title (as of NCL V6.4.0)
resP@txString = "A common title" ; old way of setting main title
resP@gsnPanelBottom = 0.05 ; add space at bottom
resP@gsnPanelFigureStrings= (/"a)","b)","c)"/) ; add strings to panel
resP@amJust = "TopLeft"
gsn_panel(wks,plot,(/3,1/),resP) ; now draw as one plot
txres = True
txres@txFontHeightF = 0.015
gsn_text_ndc(wks,"Figure 1: A nifty panel plot",0.5,0.02,txres)
frame(wks)
end