[ncl-talk] Regarding annotation

Mary Haley haley at ucar.edu
Tue Dec 5 10:10:42 MST 2017


The key to adding markers, text, lines, or polygons to a WRF plot that was
generated using wrf_map_overlays is to set the special resource "PanelPlot"
to True, which tells wrf_map_overlays to not draw the plot after the
overlay, *and* to not remove all the overlays. It looks something like this:

  mapres = True
  pltres = True
  pltres at PanelPlot = True     ; Tells wrf_map_overlays to not draw plot
and
                              ; to not remove the contours afterwards.

  plot = wrf_map_overlays(a,wks,contour,pltres,mapres)

Then you can add whatever you want to the "plot", using lat/lon values:

;---Add two dots and two text strings at location of US cities.

  lats  = (/   29.95,       33.75,      36.16,      41.88/)
  lons  = (/  -90.07,      -84.39,     -86.78,     -87.63/)
  tstrs = (/"New Orleans","Atlanta", "Nashville", "Chicago"/)
  mkres = True
  txres = True
  mkres at gsMarkerIndex = 16 ; filled dot

  txres at txFontHeightF = 0.015
  txres at txJust        = "CenterLeft"

  mkid = gsn_add_polymarker(wks,plot,lons,lats,mkres)
  txid = gsn_add_text(wks,plot,"   " + tstrs,lons,lats,txres)

  draw(plot)
  frame(wks)

I've attached a sample script and the resultant PNG, which I will add to
our example page somewhere.

--Mary


On Tue, Dec 5, 2017 at 3:59 AM, swati shewale <shewaleswati16 at gmail.com>
wrote:

> about above query, I went through function 'str_get_cols'. I understood
> it. Now I want to put single city (Ahmedabad) annotation in my plotting. I
> am afraid as am handling wrf file, Can I  accommodate it? please find the
> attachment, annotation.txt (contains single city), annotation.ncl (wish to
> put all the statements from this file to wrf_annotation.ncl so that It
> could reflect Ahmedabad city). kindly provide suggestion.
>
> On Tue, Dec 5, 2017 at 12:30 PM, swati shewale <shewaleswati16 at gmail.com>
> wrote:
>
>> Thanks a lot Mary for quick response. I did download text file provided
>> in link before running annotation_5.ncl. Actually to see values of lons in
>> print statement, I removed minus sign from below statement that leads to
>> blank plot (this I rectify while comparing with your script, thanks for
>> your time). If text file includes all positive lons, why here used minus?
>>   lons       = -tofloat(str_get_field(data,3," "))
>>
>> Also what 22 signifies in below statement
>>
>>    city_state = str_get_cols(data,22,-1)
>>
>> On Mon, Dec 4, 2017 at 9:32 PM, Mary Haley <haley at ucar.edu> wrote:
>>
>>> This example works with NCL V6.2.0 (I just verified this). However, I
>>> still highly recommend that you upgrade. V6.2.0 is 3.5 years old.
>>>
>>> Did you modify annotate_5.ncl at all?  I've attached a version that
>>> loops through each city and plots each text string and marker one at a
>>> time, just in case.
>>>
>>> This method is NOT recommended as it is slower and more memory intensive.
>>>
>>> If this continues to not work for you, then please include the full
>>> script and the annotate5.txt file you are using, so we can be sure
>>> something else isn't going on.
>>>
>>> --Mary
>>>
>>>
>>> On Mon, Dec 4, 2017 at 3:48 AM, swati shewale <shewaleswati16 at gmail.com>
>>> wrote:
>>>
>>>> Dear NCL users
>>>>
>>>> I wish to add annotations to my plot. I gone through below link.
>>>>
>>>> https://www.ncl.ucar.edu/Applications/annotate.shtml
>>>>
>>>> for time being I took example 5 (annotate_5.ncl
>>>> <https://www.ncl.ucar.edu/Applications/Scripts/annotate_5.ncl>) as it
>>>> is, It gives me plot without annotation (attached here). Is it because my
>>>> NCL version is 6.2.0?
>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171205/fd2e44e6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrf_nogsn_poly_5.ncl
Type: application/octet-stream
Size: 1851 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171205/fd2e44e6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrf_poly.png
Type: image/png
Size: 158385 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171205/fd2e44e6/attachment.png>


More information about the ncl-talk mailing list