[ncl-talk] Placing numbers above the bars

Mary Haley haley at ucar.edu
Tue Feb 19 13:29:13 MST 2019


Barry,

You can add space by increasing the Y position of the text string in the
call to gsn_text (or gsn_add_text).  For example, if the max value is 4000,
don't put the label right at 4000, but rather add a little to it, like
4005. You can also cheat by adding a carriage return at the end of the
string, e.g., instead of "label", use "label~C~" which adds one carriage
return.  For two, "label~C~~C~" and so on.

The other thing to do do is set txJust to BottomCenter, which means the
bottom center of the string is what will be positioned at your X,Y
position, and not the center center of the string.  And growing the labels
is via the txFontHeightF resource.

--Mary




On Tue, Feb 19, 2019 at 11:09 AM Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hello:
>
> I was a bit surprised do see that there are numbers above the bars now.
>
> However, they are there, so I must have really benefited from the
> information on these two pages.
>
> http://www.ncl.ucar.edu/Applications/Scripts/bar_horz_7.ncl
>
> https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_text.shtml
>
> Yet, I am wondering how I might create a bit of space between the bars and
> the labels, and how I might grow the labels (numbers) themselves?
>
> Thank you,
>
> Barry
>
> On Tue, Feb 19, 2019 at 5:33 PM Mary Haley <haley at ucar.edu> wrote:
>
>>
>> Barry,
>>
>> You can also use gsn_add_text or gsn_text to place the text above the
>> bar, using the max value of the bar and the X axis position.
>>
>> There are some examples. See bar_7.ncl at:
>>
>> http://www.ncl.ucar.edu/Applications/bar.shtml#ex7
>>
>> Histograms are slightly different, but there are also several examples of
>> labeling the bars:
>>
>> http://www.ncl.ucar.edu/Applications/histo.shtml
>>
>> See #12, and #16. This is mainly to give you some ideas of different ways
>> to label a bar.
>>
>> --Mary
>>
>>
>>
>>
>> On Sun, Feb 17, 2019 at 9:17 AM Rick Brownrigg <brownrig at ucar.edu> wrote:
>>
>>> Hi Barry,
>>>
>>> You might be able to use "datatondc()" to get the NDC coordinates of the
>>> tops of the bars, and then use gsn_text_ndc() to draw your annotation
>>> (applying a small offset in x and/or y direction to properly position it).
>>> The example on the datatondc() does something similar, but with markers
>>> rather than text.
>>>
>>>     http://ncl.ucar.edu/Document/Functions/Built-in/datatondc.shtml
>>>     http://ncl.ucar.edu/Document/Graphics/Interfaces/gsn_text_ndc.shtml
>>>
>>> Hope that helps...
>>> Rick
>>> On Sat, Feb 16, 2019 at 11:05 PM Barry Lynn <barry.h.lynn at gmail.com>
>>> wrote:
>>>
>>>> Hello:
>>>>
>>>> I have a bar chart attached.
>>>>
>>>> I would like to place a number (I will generate it) above the position
>>>> of the bar highest bar, centered at each labeled (x-axis) interval.
>>>>
>>>> Is there a straightforward way to do this?
>>>>
>>>> Thanks,
>>>>
>>>> Barry
>>>>
>>>> --
>>>> Barry H. Lynn, Ph.D
>>>> Senior Associate Scientist, Lecturer,
>>>> The Institute of the Earth Science,
>>>> The Hebrew University of Jerusalem,
>>>> Givat Ram, Jerusalem 91904, Israel
>>>> Tel: 972 547 231 170
>>>> Fax: (972)-25662581
>>>>
>>>> C.E.O, Weather It Is, LTD
>>>> Weather and Climate Focus
>>>> http://weather-it-is.com
>>>> Jerusalem, Israel
>>>> Local: 02 930 9525
>>>> Cell: 054 7 231 170
>>>> Int-IS: x972 2 930 9525
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>
> --
> Barry H. Lynn, Ph.D
> Senior Associate Scientist, Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190219/2dc06396/attachment.html>


More information about the ncl-talk mailing list