<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Dear ncl-support</p>
<p> I'm generating a contour_map plot for the ocean temperature <br>
</p>
<p> I would like to generate a png with a background transparent beacause I want overlay the map on google map.
<br>
</p>
<p> I'm using the following scripts but I got a white background</p>
<p><br>
</p>
<p> How can I get a transparent background?<br>
</p>
<p>thanks</p>
<p>Francesco <br>
</p>
<p><br>
</p>
<p><br>
</p>
<p> ;============== open a file ========================================<br>
wks = gsn_open_wks(typefile,namefile)<br>
<br>
setvalues NhlGetWorkspaceObjectId()<br>
"wsMaximumSize" : 300000000<br>
end setvalues<br>
<br>
;============== miscellanous =======================================<br>
gsn_define_colormap(wks,colorsMap)<br>
<br>
;============== map resources ======================================<br>
res = True<br>
;--- Title attributes -----------------------------------<br>
res@tiMainFont = 0<br>
res@tiMainPosition = "Center"<br>
res@tiMainFontHeightF = 0.011<br>
;res@tiMainOffsetYF = 0.01<br>
;--- GSN attributes -------------------------------------<br>
res@gsnDraw = False<br>
res@gsnFrame = False<br>
res@gsnMaximize = True<br>
res@gsnAddCyclic = False <br>
res@gsnSpreadColors = True<br>
;--- Map attributes (window) ----------------------------<br>
res@mpLimitMode = "LatLon" ;Zoom in on the plot area<br>
res@mpMinLatF = minLatF<br>
res@mpMaxLatF = maxLatF<br>
res@mpMinLonF = minLonF<br>
res@mpMaxLonF = maxLonF<br>
;--- Map attributes (projection) ----------------------------<br>
res@mpProjection = "mercator"<br>
;--- Map attributes (land outlines) ---------------------<br>
res@mpDataBaseVersion = "HighRes" ;use GMT coastline<br>
res@mpOutlineOn = lmapOutlineOn ;turn on continental outlines<br>
res@mpOutlineBoundarySets = "AllBoundaries" ;turn on country boundaries (all the boundaries database in use)<br>
res@mpGeophysicalLineThicknessF = 2.5 ;thickness of outlines<br>
res@mpGeophysicalLineColor= "Black" ;color of cont. outlines<br>
res@mpOutlineDrawOrder = "PostDraw" ;draw continental outline last<br>
res@mpFillOn = False ;turn on gray fill for continental background<br>
res@pmTickMarkDisplayMode = "Always"<br>
;--- Map attributes (lat/lon grid lines) ----------------<br>
res@mpGridAndLimbOn = False ;turn on lat/lon lines<br>
res@mpGridLineDashPattern = 2 ;... with xxxx lines<br>
res@mpGridLineColor = "black" ;color of the lines<br>
res@mpGridLatSpacingF = 10 ;space (in degree) between 2 lines<br>
res@mpGridLonSpacingF = 10 ;idem<br>
res@mpGridLineThicknessF = 2.0 ;thickness of the lines<br>
res@mpGridAndLimbDrawOrder= "PostDraw" ;draw lat/lon lines last<br>
res@mpLabelFontHeightF = 0.005 ;label font size<br>
;--- contours attributes --------------------------------<br>
res@cnFillOn = True ;areas between levels filled with color<br>
res@cnFillMode = "AreaFill" ;AreaFill<br>
res@cnLevelSelectionMode = "ManualLevels" ;set manual contour levels<br>
res@cnMinLevelValF = minLevelVal ;set max contour level<br>
res@cnMaxLevelValF = maxLevelVal ;set min contour level<br>
res@cnLevelSpacingF = levelSpacing<br>
res@cnLinesOn = False ;turn off the contour lines<br>
res@cnLineLabelsOn = False ;turn off the line labels<br>
res@cnLineLabelFontHeightF= 0.005<br>
res@cnLineLabelDensityF = 1 ;label spacing when cnLineLabelPlacementMode != "Constant"<br>
res@cnLineLabelFontAspectF= 1 ;shape of the line label. > 1 :thinner characters. < 1 :wider<br>
res@cnLineLabelInterval = 1<br>
res@cnInfoLabelOn = False ;turn off "CONTOUR FROM X TO X BY X" legend.<br>
res@cnLabelMasking = True ;mask lines where label appear<br>
res@cnConstFEnableFill = True ;allow constant values (1=sig) to fill<br>
res@cnConstFLabelOn = False<br>
;--- LabelBar attributes --------------------------------<br>
res@lbLabelBarOn = llabbarOn<br>
res@lbLabelsOn = llabbarLabelsOn<br>
;res@lbTitleString = "("+field@units+")"<br>
res@lbOrientation = "vertical" ; vertical label bar<br>
;res@pmLabelBarHeightF = 0.7<br>
res@lbTitlePosition = "Bottom"<br>
res@lbAutoManage = False ; Necessary to control sizes<br>
res@pmLabelBarWidthF = 0.1 ; default is shorter<br>
;res@pmLabelBarHeightF = 0.1 ; default is taller<br>
;res@lbLabelFontHeightF = .018 ; default is HUGE<br>
res@lbPerimOn = False ; default has box<br>
res@lbLeftMarginF = 0.0 <br>
res@lbTopMarginF = 0.0 ; eliminate any margin at the top and left of the colorbar<br>
res@lbBottomMarginF = 0.0 ; eliminate any margin at the top and left of the colorbar<br>
res@lbLabelOffsetF = .05 ; this specifies the offset between the colorbar and the labels as a fraction of vpWidthF
<br>
res@lbLabelAutoStride = True ; (optional) this ensures that labels do not overlap when the font height is made very large.<br>
res@lbLabelFontHeightF = 0.015<br>
res@lbTitleFontHeightF = 0.015<br>
;res@lbLabelStride = 5 ; Label every 5th entry<br>
if (ismissing(minLevelVal) .or. ismissing(maxLevelVal)) then res@lbLabelStrings = ""
<br>
else res@lbLabelStrings = "" + sprintf(labformatStr,fspan(minLevelVal,maxLevelVal, \<br>
floattoint((maxLevelVal-minLevelVal)/levelSpacing)+1)) end if<br>
<br>
;-------------- scalars attributes ----------------------<br>
res@sfXArray = lon2d(0:ny-1,0:nx-1) ; abscisses<br>
res@sfYArray = lat2d(0:ny-1,0:nx-1) ; ordonnees<br>
<br>
;=== draw contour/contour lines ====================================<br>
plot = gsn_csm_contour_map(wks,field(:,:),res)<br>
<br>
draw(plot)<br>
frame(wks)<br>
<br>
system("convert -alpha off -background white -geometry "+typefile@wkWidth+"x"+typefile@wkHeight+ \<br>
" -density 300 -trim "+namefile+".png "+namefile+".png")<br>
<br>
</p>
</body>
</html>