[ncl-talk] Add text and polymarkers on panel plots
Tabish Ansari
tabishumaransari at gmail.com
Thu Apr 25 11:21:13 MDT 2019
Hi
I'm able to add text and polymarkers of separate plots but not able to
panel them properly. The text and polymarkers are being added on the
original plots and then a panel is being displayed on top of that without
the text and polymarkers.
Here's my code:
*load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load
"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"beginncol = 2 ; THE TWO
COLUMNS REPRESENT 2 DAYS: 24TH AND 30TH OCTOBERdata =
readAsciiTable("/home/tabish/Emulation/EmulPreds_responsesurface_Run2.csv",
ncol, "float", 1); THIS WILL IGNORE THE 1ST ROW WHICH IS
HEADERdata at _FillValue = -999print("table read-in
successfully")printVarSummary(data);TRANSFORMING 144X1 STRUCTURE TO 12X12
STRUCTURE FOR CONTOUR PLOTc=0a = new((/12,12/),float);MATRIX TO HOLD VALUES
FOR 24TH OCTb = new((/12,12/),float);MATRIX TO HOLD VALUES FOR 30TH OCTdo
i=0,11 do j=0,11 a(i,j) = data(c,0) b(i,j) = data(c,1) c = c+1 end doend
do;ROUNDING OFF THE PM2.5 VALUES FOR CLEAN PRINTINGa = round(a,0)b =
round(b,0);ATTACHING 0-120% COORDINATE ARRAYS x = ispan(0,110,10) y
= ispan(0,110,10) a!0 = "x" a!1 = "y" a&x = x a&y = y b!0 = "x" b!1 =
"y" b&x = x b&y = y wks = gsn_open_wks("x11","RS") ; Send graphics to
PNG file; Set up resources. res = True
res at gsnFrame = False ; Turn off so we can add markers
and text res at gsnMaximize = False res at cnFillOn =
True ; Turn on contour fill res at cnFillPalette = "amwg" ;
Set color map res at tiYAxisFontHeightF = 0.018 res at tiXAxisFontHeightF =
0.018 res at tiYAxisString = "Near neighbourhood (Ind+pow+res+tran)"
res at pmTitleZone = 3 res at tiXAxisString = "Beijing
(Ind+pow+res+tran)" res at cnFillMode = "RasterFill"
res at cnLinesOn = False res at lbOrientation = "vertical"
res at tmXBMajorOutwardLengthF = 0.0 ; draw tickmarks inward
res at tmXBMinorOutwardLengthF = 0.0 ; draw minor ticks inward
tmXTMajorOutwardLengthF = 0.0 ; draw tickmarks inward
res at tmXTMinorOutwardLengthF = 0.0 ; draw minor ticks inward
res at tmYLMajorOutwardLengthF = 0.0 ; draw tickmarks inward
res at tmYLMinorOutwardLengthF = 0.0 ; draw minor ticks inward
res at tmYRMajorOutwardLengthF = 0.0 ; draw tickmarks inward
res at tmYRMinorOutwardLengthF = 0.0 ; draw minor ticks inward
;res at tmXBMode = "Explicit" ;res at tmXBValues = ispan(0,120,10)
plot1 = gsn_csm_contour(wks,a,res) ; Create filled contours plot2 =
gsn_csm_contour(wks,b,res) ; Create filled contours;---Draw text and
markers at data locations txres = True mkres
= True txres at txFontHeightF = 0.01 txres at txJust = "TopCenter" ;
text will be drawn under the marker mkres at gsMarkerIndex = 16 ; filled
circle do j=0,11 do i=0,11
gsn_polymarker(wks,plot1,x(i),y(j),mkres) gsn_text(wks,plot1,"
~C~"+a(j,i),x(i),y(j),txres)
gsn_polymarker(wks,plot2,x(i),y(j),mkres) gsn_text(wks,plot2,"
~C~"+b(j,i),x(i),y(j),txres) end do end do;
frame(wks);************************************************; create
panel;************************************************resP =
True;resP at gsnPanelYWhiteSpacePercent =
0.0gsn_panel(wks,(/plot1,plot2/),(/1,2/),resP) ; now draw as
one plotend*
Cheers,
Tabish
Tabish U Ansari
PhD student, Lancaster Environment Center
Lancaster Univeristy
Bailrigg, Lancaster,
LA1 4YW, United Kingdom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190425/191d19ae/attachment.html>
More information about the ncl-talk
mailing list