<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi Adam,</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks for pointing me to the right functions.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">The gsn_add* functions throw a return value which needs to be stored in a uniquely named variable each time.<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">As you can see in my script that I want to draw the polymarkers and attach the text at every 10th grid point in the 2D-array (It's 120x120 grids).</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I'm able to draw them using gsn_text and gsn_polymarker but not using the corresponding gsn_add* functions. NCL doesn't give any error, but the polymarkers and text aren't printed.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Here's my updated script:</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><i>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br><br>begin<br><br>ncol = 11 ; COLUMNS CORRESPOND TO THE 11 DAYS HERE<br>data = readAsciiTable("/home/tabish/Emulation/EmulPreds_responsesurface_Run8.csv", ncol, "float", 1); THIS WILL IGNORE THE 1ST ROW WHICH IS HEADER<br>data@_FillValue = -999<br>print("table read-in successfully")<br>printVarSummary(data)<br><br>;TRANSFORMING 14400X1 STRUCTURE TO 120X120 STRUCTURE FOR CONTOUR PLOT<br>c=0<br>a = new((/120,120/),float);MATRIX TO HOLD VALUES FOR 24TH OCT<br>b = new((/120,120/),float);MATRIX TO HOLD VALUES FOR 30TH OCT<br>do i=0,119<br> do j=0,119<br> a(i,j) = data(c,3);THIS MATRIX STORES VALUES FOR 24TH OCT<br> b(i,j) = data(c,9);THIS MATRIX STORES VALUES FOR 30TH OCT<br> c = c+1<br> end do<br>end do<br><br>;ATTACHING 0-120% COORDINATE ARRAYS<br> x = ispan(0,119,1)<br> y = ispan(0,119,1)<br><br> a!0 = "x"<br> a!1 = "y"<br> a&x = x<br> a&y = y<br><br> b!0 = "x"<br> b!1 = "y"<br> b&x = x<br> b&y = y<br><br> wks = gsn_open_wks("x11","30OctRS_Beijing-IR_vs_Beijing-TP") ; Send graphics to PNG file<br><br>; Set up resources.<br> res = True<br> res@gsnFrame = False ; Turn off so we can add markers and text<br> res@gsnMaximize = False<br> res@cnFillOn = True ; Turn on contour fill<br> res@cnFillPalette = "BlGrYeOrReVi200" ; Set color map<br> ; res@cnFillPalette = "WhiteBlue" ; Set color map<br> res@tiYAxisFontHeightF = 0.018 <br> res@tiXAxisFontHeightF = 0.018 <br> res@tiYAxisString = "Beijing(Pow+Tran)"<br> res@pmTitleZone = 3<br> res@tiXAxisString = "Beijing(Ind+Res)"<br> ;res@cnFillMode = "RasterFill"<br> res@cnLinesOn = False<br> res@lbOrientation = "vertical"<br> res@tmXBMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmXBMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br> tmXTMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmXTMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br> res@tmYLMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmYLMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br> res@tmYRMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmYRMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br>; plot1 = gsn_csm_contour(wks,a,res) ; Create filled contours<br> plot2 = gsn_csm_contour(wks,b,res) ; Create filled contours<br><br>;---Draw text and markers at data locations<br> txres = True<br> mkres = True<br> txres@txFontHeightF = 0.01<br> txres@txJust = "TopCenter" ; text will be drawn under the marker<br> mkres@gsMarkerIndex = 16 ; filled circle<br><br>;ROUNDING OFF THE PM2.5 VALUES FOR CLEAN PRINTING<br>a = round(a,0)<br>b = round(b,0)<br><br>dumpoly1 = new(25,graphic)<br>dumpoly2 = new(25,graphic)<br>dumtext1 = new(25,graphic)<br>dumtext2 = new(25,graphic)<br>c=0; counter variable for dummy variables<br> do j=0,100,20<br> do i=0,100,20<br> if((i.gt.0).and.(j.gt.0)) then <br> print(i+","+j)<br>; gsn_polymarker(wks,plot1,x(i-1),y(j-1),mkres)<br>; gsn_text(wks,plot1," ~C~"+a(j-1,i-1),x(i-1),y(j-1),txres)<br> dumpoly2(c) = gsn_add_polymarker(wks,plot2,x(i-1),y(j-1),mkres)<br> dumtext2(c) = gsn_add_text(wks,plot2," ~C~"+b(j-1,i-1),x(i-1),y(j-1),txres)<br> c = c+1<br> end if<br> end do<br> end do<br><br> frame(wks)<br><br>;************************************************<br>; create panel<br>;************************************************<br>;resP = True<br>;resP@gsnPanelYWhiteSpacePercent = 0.0<br>;gsn_panel(wks,(/plot1,plot2/),(/1,2/),resP) ; now draw as one plot<br><br>end</i><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Cheers,</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br clear="all"></div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 25 Apr 2019 at 19:00, Adam Phillips <<a href="mailto:asphilli@ucar.edu">asphilli@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Tabish,<div>If you are adding polymarkers/text to plots that are being paneled, you have to use the gsn_add_polymarker/gsn_add_text functions due to limitations with gsn_text/gsn_polymarker. See the documentation for the two add functions here:</div><div><a href="http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_text.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_text.shtml</a><br></div><div><a href="http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_polymarker.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_polymarker.shtml</a><br></div><div>Adam</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 25, 2019 at 11:21 AM Tabish Ansari <<a href="mailto:tabishumaransari@gmail.com" target="_blank">tabishumaransari@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Hi <br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">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.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Here's my code:</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><i>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br><br>begin<br><br>ncol = 2 ; THE TWO COLUMNS REPRESENT 2 DAYS: 24TH AND 30TH OCTOBER<br>data = readAsciiTable("/home/tabish/Emulation/EmulPreds_responsesurface_Run2.csv", ncol, "float", 1); THIS WILL IGNORE THE 1ST ROW WHICH IS HEADER<br>data@_FillValue = -999<br>print("table read-in successfully")<br>printVarSummary(data)<br><br>;TRANSFORMING 144X1 STRUCTURE TO 12X12 STRUCTURE FOR CONTOUR PLOT<br>c=0<br>a = new((/12,12/),float);MATRIX TO HOLD VALUES FOR 24TH OCT<br>b = new((/12,12/),float);MATRIX TO HOLD VALUES FOR 30TH OCT<br>do i=0,11<br> do j=0,11<br> a(i,j) = data(c,0)<br> b(i,j) = data(c,1)<br> c = c+1<br> end do<br>end do<br><br>;ROUNDING OFF THE PM2.5 VALUES FOR CLEAN PRINTING<br>a = round(a,0)<br>b = round(b,0)<br>;ATTACHING 0-120% COORDINATE ARRAYS<br> x = ispan(0,110,10)<br> y = ispan(0,110,10)<br><br> a!0 = "x"<br> a!1 = "y"<br> a&x = x<br> a&y = y<br><br> b!0 = "x"<br> b!1 = "y"<br> b&x = x<br> b&y = y<br><br> wks = gsn_open_wks("x11","RS") ; Send graphics to PNG file<br><br>; Set up resources.<br> res = True<br> res@gsnFrame = False ; Turn off so we can add markers and text<br> res@gsnMaximize = False<br> res@cnFillOn = True ; Turn on contour fill<br> res@cnFillPalette = "amwg" ; Set color map<br> res@tiYAxisFontHeightF = 0.018 <br> res@tiXAxisFontHeightF = 0.018 <br> res@tiYAxisString = "Near neighbourhood (Ind+pow+res+tran)"<br> res@pmTitleZone = 3<br> res@tiXAxisString = "Beijing (Ind+pow+res+tran)"<br> res@cnFillMode = "RasterFill"<br> res@cnLinesOn = False<br> res@lbOrientation = "vertical"<br> res@tmXBMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmXBMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br> tmXTMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmXTMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br> res@tmYLMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmYLMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br> res@tmYRMajorOutwardLengthF = 0.0 ; draw tickmarks inward<br> res@tmYRMinorOutwardLengthF = 0.0 ; draw minor ticks inward<br><br><br><br> ;res@tmXBMode = "Explicit"<br> ;res@tmXBValues = ispan(0,120,10)<br> plot1 = gsn_csm_contour(wks,a,res) ; Create filled contours<br> plot2 = gsn_csm_contour(wks,b,res) ; Create filled contours<br><br>;---Draw text and markers at data locations<br> txres = True<br> mkres = True<br> txres@txFontHeightF = 0.01<br> txres@txJust = "TopCenter" ; text will be drawn under the marker<br> mkres@gsMarkerIndex = 16 ; filled circle<br><br> do j=0,11<br> do i=0,11<br> gsn_polymarker(wks,plot1,x(i),y(j),mkres)<br> gsn_text(wks,plot1," ~C~"+a(j,i),x(i),y(j),txres)<br> gsn_polymarker(wks,plot2,x(i),y(j),mkres)<br> gsn_text(wks,plot2," ~C~"+b(j,i),x(i),y(j),txres)<br> end do<br> end do<br>; frame(wks)<br><br>;************************************************<br>; create panel<br>;************************************************<br>resP = True<br>;resP@gsnPanelYWhiteSpacePercent = 0.0<br>gsn_panel(wks,(/plot1,plot2/),(/1,2/),resP) ; now draw as one plot<br><br>end<br></i></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Cheers,</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Tabish<br clear="all"></div><div><div dir="ltr" class="gmail-m_616086272226433927gmail-m_-835746078311605564gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_616086272226433927gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist, </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a> </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div>