[ncl-talk] gsn_add_txt in panel plot

Debasish Hazra debasish.hazra5 at gmail.com
Tue Nov 30 18:49:33 MST 2021


Thanks Adam. I added
dum2=gsn_add_text(wks,plot_A(0),"Test",lond(0)+1,latd(0)+1,False)  and it
worked. "Test" appeared on the first figure. I am wondering what is going
on, why dum2=gsn_add_text(wks,plot_A(0),strs(0),-28,23,txres)   one did not
work at first place ?

Debasish

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

> Ah, I misread what you sent. Just checking: Did you set res at gsnDraw/gsnFrame
> = False? I do not see anything wrong with your code. What happens if you
> set this for the first gsn_add_text call:
>  dum2=gsn_add_text(wks,plot_A(0),"Test",lond(0)+1,latd(0)+1,False)
>
> If doing that doesn't help, then I would recommend simplifying your script
> and isolating the first panel in your coding and see if you can get the
> text to appear when only the first panel is drawn. Eliminate all/most
> resources and see if that gets the text to show up.
> Hope that helps!
> Adam
>
>
> On Tue, Nov 30, 2021 at 3:15 PM Debasish Hazra <debasish.hazra5 at gmail.com>
> wrote:
>
>> 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>
>>>
>>
>
> --
> 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/9106c189/attachment.html>


More information about the ncl-talk mailing list