[ncl-talk] Marker labels

Rick Brownrigg brownrig at ucar.edu
Thu Feb 15 10:47:49 MST 2018


HI,

One possible way to do that would be, as you draw each marker, find out out
where its center is in Normalized Coordinate Space (NDC, effective
coordinates on the "page" ranging from 0 to 1), and a small offset to that
and call gsn_text_ndc() to draw the label. So, using the newcolor_4
example, do *something like* (untested):

do i=0,nlevels-2
    ii = ind(levels(i).le.dvals.and.dvals.lt.levels(i+1))

...
    dum_fill_opq(i) = gsn_add_polymarker(wks,map_opq,lon(ii),lat(ii),mkres)

;---Add outlines

; ---Label the markers

    datatondc(map_opq, lon(ii), lat(ii), xNDC, yNDC)

    gsn_text_ndc(wks, map_opq, myMarkerLabels(ii), xNDC+xOffset,
yNDC+yOffset, textRes)
...
    delete(ii)
  end do

There are of course some details there you'll need to fill in (eg,
myMarkerLabel, textRes, etc), but those two function calls will get you
close. Also, with this simple scheme, there's the potential for overlapping
labels if the markers are dense. But hopefully this will get you started.

Rick

On Thu, Feb 15, 2018 at 10:29 AM, Manisha Ganeshan <
manisha.ganeshan86 at gmail.com> wrote:

> Dear NCL'ers,
>
> I had a question w.r.t the example script "newcolor_4.ncl" under polygons,
> polymarkers, polylines, text. I was wondering how I might add a label
> identifying each colored marker.
>
> Thanks,
> Nisha
>
> --
> Dr. Manisha Ganeshan
> Universities Space Research Association
> Maryland, U.S.A.
>
> _______________________________________________
> 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/20180215/a932aff2/attachment.html>


More information about the ncl-talk mailing list