[ncl-talk] Add text and polymarkers on panel plots

Adam Phillips asphilli at ucar.edu
Thu Apr 25 11:59:34 MDT 2019


Hi Tabish,
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:
http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_text.shtml
http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_polymarker.shtml
Adam

On Thu, Apr 25, 2019 at 11:21 AM Tabish Ansari <tabishumaransari at gmail.com>
wrote:

> 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
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190425/8a25fc90/attachment.html>


More information about the ncl-talk mailing list