[ncl-talk] annotated map on contour plot is transparent rather than white

Jatin Kala jatin.kala.jk at gmail.com
Sun Feb 21 22:51:58 MST 2016


Hi,
I am annotating a map on top of a contour plot. However, the map is 
being plotted as transparent rather than with white background.
See attached, any suggestions on how to fix this? I've tried a couple of 
things, none have worked so far.
Cheers,
Jatin
-------------- next part --------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "/home/z3381484/hdrive/NCL/ncl-functions/cordex_grid_plot_functions.ncl"
load "/home/z3381484/hdrive/NCL/ncl-functions/lambert_grid_plot_functions.ncl"
load "/home/z3381484/hdrive/NCL/ncl-functions/querry_awap.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

; File Name : plot_Trudy_precip.ncl

; Purpose :

; Creation Date : 19-02-2016

; Last Modified : Mon 22 Feb 2016 16:45:56 AEDT

; Created By : Jatin Kala (Jatin.Kala.JK at gmail.com)

begin
f = addfile("/srv/ccrc/data39/z3381484/Trudy_Papp/AWAP_Year_Precip_mean_2001_2014.nc","r")
precip = f->all_precip_mean_mask
precip at _FillValue = 9.96921e+36 
lat = f->lat2d
lon = f->lon2d
precip at lat2d = lat
precip at lon2d = lon

type = "pdf"
res = True
colmap = "BlAqGrYeOrReVi200" ;"ViBlGrWhYeOrRe"
res at gsnSpreadColorEnd = 2
res at gsnSpreadColorStart = -1
res at cnFillOn              = True     ; turn on color fill
res at cnLinesOn             = False    ; turn of contour lines
res at cnLineLabelsOn        = False
res at gsnSpreadColors       = True     ; use full range of color map
res at gsnAddCyclic          = False    ; data already has cyclic point
res at gsnDraw               = False
res at gsnFrame              = False
res at mpMinLatF            = -36.0 ;min(lat2d)     ; range to zoom in on
res at mpMaxLatF            = -30.0 ;max(lat2d)
res at mpMinLonF            = 114.5 ;min(lon2d)
res at mpMaxLonF            = 121.0 ;max(lon2d)
res at mpGridSpacingF       = 1.0
res at mpDataBaseVersion = "HighRes"
res at lbLabelBarOn = True
res at cnLevelSelectionMode = "ManualLevels"
res at cnMaxLevelValF = 800.0
res at cnMinLevelValF = 100.0
res at cnLevelSpacingF = 25.0
res at tmXTOn = False
res at tmYROn = False

lats = (/-33.243963,  -34.288593 ,  -34.907939 /)
longs = (/115.93955,  116.450109, 117.037832/)
str = (/"a","b","c"/)
respl = True
respl at gsMarkerIndex = 16
resTx = True
resTx at txFontHeightF = 0.01

wks = gsn_open_wks(type,"pdf_out/Trudy_precip_map")
setvalues wks
      "wkBackgroundColor" : "white"
      "wkForegroundColor" : "black"
end setvalues 
gsn_define_colormap(wks,colmap)
map = gsn_csm_contour_map_ce(wks,precip,res)
dum = gsn_add_polymarker(wks,map,longs,lats,respl)
dumt = gsn_add_text(wks,map,str,longs+0.1,lats+0.1,resTx)

; add Perth and Albany
mstring = "y"
fontnum = 35
xoffset = 0.0
yoffset = 0.0
ratio   = 1.0
size    = 1.0
angle   = 0.0
new_index = NhlNewMarker(wks, mstring, fontnum, xoffset, yoffset, ratio, size, angle)
respl at gsMarkerIndex = new_index
dum_p = gsn_add_polymarker(wks,map,(/115.8589,117.884/),(/-31.9522,-35.024/),respl)
resTx at txFontHeightF = 0.018
dum_perth = gsn_add_text(wks,map,"Perth",115.2,-32.0,resTx)
dum_alb = gsn_add_text(wks,map,"Albany",118.0,-35.5,resTx)

;draw map of australia to annotate
res1 = True
res1 at gsnDraw = False
res1 at gsnFrame = False
res1 at mpMinLatF = min(lat)
res1 at mpMaxLatF = max(lat)
res1 at mpMinLonF = min(lon)
res1 at mpMaxLonF = max(lon)
res1 at tmXTOn = False
res1 at tmXBOn = False
res1 at tmYROn = False
res1 at tmYLOn = False
res1 at mpFillOn = False
res1 at mpOutlineBoundarySets = "National"
res1 at mpDataBaseVersion = "MediumRes"            ; choose higher resolution
res1 at mpDataSetName = "Earth..4"                 ; choose most recent boundaries
res1 at mpOutlineSpecifiers = "Australia:states"
; make it smaller
res1 at vpHeightF = 0.2
res1 at vpWidthF = 0.2
res1 at mpLandFillColor         = "Grey"
res1 at mpOceanFillColor        = "White"
res1 at mpInlandWaterFillColor  = "White"

map_aus = gsn_csm_map_ce(wks,res1)
; add grid
resl = True
resl at gsLineDashPattern = 1
resl at gsLineThicknessF = 1.5
dum1 = gsn_add_polyline(wks,map_aus,(/res at mpMinLonF, res at mpMinLonF/),(/res at mpMinLatF,res at mpMaxLatF/),resl)
dum2 = gsn_add_polyline(wks,map_aus,(/res at mpMaxLonF, res at mpMaxLonF/),(/res at mpMinLatF,res at mpMaxLatF/),resl)
dum3 = gsn_add_polyline(wks,map_aus,(/res at mpMinLonF, res at mpMaxLonF/),(/res at mpMinLatF,res at mpMinLatF/),resl)
dum4 = gsn_add_polyline(wks,map_aus,(/res at mpMinLonF, res at mpMaxLonF/),(/res at mpMaxLatF,res at mpMaxLatF/),resl)

resTx at txFontHeightF = 0.0125
dum5 = gsn_add_text(wks,map_aus,"Map area",121.5,-39.0,resTx)

; annoate
amres = True
amres at amJust = "TopRight"
amres at amParallelPosF = 0.5
amres at amOrthogonalPosF = -0.5
map_annno = gsn_add_annotation(map,map_aus,amres)

draw(map)
frame(wks)

delete([/wks,map/])
system("pdfcrop pdf_out/Trudy_precip_map.pdf pdf_out/Trudy_precip_map.pdf")


end ; this ends begin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Trudy_precip_map.pdf
Type: application/pdf
Size: 197168 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160222/96bd6300/attachment.pdf 


More information about the ncl-talk mailing list