[ncl-talk] gsn_add_txt in panel plot

Debasish Hazra debasish.hazra5 at gmail.com
Tue Nov 30 15:15:27 MST 2021


Thanks Adam for the reply. Actually I want the circles and text shown in
the first figure only, not in the rest 11 ones. So, I do not need to create
any dummy variables for other figures. But the figure it generates only has
the marker circles but no texts in the first figure.

On Tue, Nov 30, 2021 at 5:07 PM Adam Phillips <asphilli at ucar.edu> wrote:

> Hi Debasish,
> Make sure you are naming the return variables different names for each
> call to gsn_add_text. You stopped showing your gsn_add_text calls after the
> first set, but the second set should be:
> dum4=gsn_add_text(wks,plot_A(0),strs(2),-38,50,txres)
> dum5=gsn_add_text(wks,plot_A(0),strs(3),-36,40,txres)
> res at gsnCenterString   = labes(1)
> plot_A(1) = gsn_csm_contour_map_ce (wks, msd2(:,:), res)
> dum6 = ...
> dum7 = ...
>
> alternatively, set up a 2D array to hold everything:
> dum = new((/12,5/),graphic)
> plot_A(0) = gsn_csm_contour_map_ce (wks, msd1(:,:), res)
> dum(0,0)=gsn_add_polymarker(wks,plot_A(0),lond,latd,mkres)
> dum(0,1)=gsn_add_text(wks,plot_A(0),strs(0),-28,23,txres)
> dum(0,2)=gsn_add_text(wks,plot_A(0),strs(1),-23,27,txres)
> dum(0,3)=gsn_add_text(wks,plot_A(0),strs(2),-38,50,txres)
> dum(0,4)=gsn_add_text(wks,plot_A(0),strs(3),-36,40,txres)
> res at gsnCenterString   = labes(1)
> plot_A(1) = gsn_csm_contour_map_ce (wks, msd2(:,:), res)
> dum(1,0)= ...
> dum(1,1)= ...
> ...
>
> Hope that helps!
> Adam
>
>
>
> On Tue, Nov 30, 2021 at 11:28 AM Debasish Hazra via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> I am trying to add gsn_add_txt and polymarks in panel plot of 12 figures
>> with 1st figure will show locations and index of stations but in the final
>> figure I am getting the circles but not texts in the figure itself.
>> Following is part of the code where I am setting up my ncl code to add
>> polyres and txts. Any help on this would be appreciated.
>>
>> res      = True               ; plot options desired
>>   res at gsnAddCyclic = False
>>   res at gsnMajorLatSpacing = 10             ; change maj lat tm spacing
>>   res at gsnMajorLonSpacing = 20
>> SNIP........
>> mkres = True
>>     mkres at gsMarkerIndex = 17     ; Filled circle
>>     mkres at gsMarkerSizeF = 0.02
>>
>>      latd = (/24.7,26.73, 49.09,38.43/)
>>     lond = (/-26.95,-22.93,-38.02, -36.24/)
>>
>>          polyres               = True          ; poly marker mods desired
>>      polyres at gsMarkerIndex = 17            ; choose circle as polymarker
>>      polyres at gsMarkerSizeF = 0.01           ; select size to avoid
>> streaking
>>      polyres at gsMarkerColor = (/"red"/)   ; choose color
>>
>>         txres = True
>>         txres at txFont        = 19           ; Change the default font.
>>         txres at txFontHeightF = 0.008         ; Set the font height.
>>         txres at txJust        = "TopLeft"
>>         txres at txFontColor   = "Black"
>> ;;         txres at txFont = "helvetica-bold"
>>        txres at txFuncCode    = "~"
>>            strs = (/"1","2","3","4"/)
>>
>>           res at gsnCenterString   = labes(0)
>>         plot_A(0) = gsn_csm_contour_map_ce (wks, msd1(:,:), res)
>>         dum1=gsn_add_polymarker(wks,plot_A(0),lond,latd,mkres)
>>         dum2=gsn_add_text(wks,plot_A(0),strs(0),-28,23,txres)
>>         dum3=gsn_add_text(wks,plot_A(0),strs(1),-23,27,txres)
>>         dum4=gsn_add_text(wks,plot_A(0),strs(2),-38,50,txres)
>>         dum5=gsn_add_text(wks,plot_A(0),strs(3),-36,40,txres)
>>         res at gsnCenterString   = labes(1)
>>         plot_A(1) = gsn_csm_contour_map_ce (wks, msd2(:,:), res)
>> SNIP.......
>>  gsn_panel(wks,plot_A,(/3,4/),pres1)
>>
>> ;        draw(plot_A)
>>         frame(wks)
>>
>> Thanks
>> Debasish
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at mailman.ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> https://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: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20211130/47f1d950/attachment.html>


More information about the ncl-talk mailing list