[ncl-talk] At the top of this page on histograms

Mary Haley haley at ucar.edu
Mon Mar 19 11:35:38 MDT 2018


Barry,

I'm not sure exactly what you want.
​  Indicating what kind of histogram you want and setting the labels you
want on the X axis are two different things.

​First, you need to be clear about what kind of histogram you want. There
are two kinds: interval and discrete.​
​

By default, gsn_histogram does the binning using intervals.  If you set:

intervals = ((/8,12,18,24,30,36,50,75,100/))
res at gsnHistogramBinIntervals  = intervals


Then NCL will count all values in your data that are
​:

  first bar:   8 ​
>= and <
​12
  second bar:  ​12
>= and < 18
​   third bar:  ​18
>= and < 24
​
  and so on​

​If you set the gsnHistogramDiscreteBinValues resource, then this is a
discrete histogram:

intervals = ((/8,12,18,24,30,36,50,75,100/))
res at gsnHistogramDiscreteBinValues  = intervals


​The bars will then be:

  first bar:  all values equal to 8
  second bar: all values equal to 12
  third bar:  all values equal to 18
  and so on

The error you're getting seems to indicate that you are picking bin
intervals (or discrete values) that don't match up with what you have in
your data.

The labels that you put on the X axis can be whatever you want. Please look
at histo_3.ncl and histo_15.ncl for examples on how to set the X axis
labels.

If you continue to have problems, make sure you look at your data and
verify that it is in the range of the intervals or discrete values that you
are selecting.  Discrete values can be a problem because they have to be
EXACTLY equal to that value. This is really only useful if you have integer
or long data.

--Mary

​

On Mon, Mar 19, 2018 at 11:03 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hello:
>
> Thank you for the suggestion.
>
> I've tried a few things, but the problem I have is that I need the labels
> to be equal to the values in the variable "intervals."
>
> intervals = ((/8,12,18,24,30,36,50,75,100/))
>
>
> where the right most value displayed on the histogram is 75.
>
>
> I tried setting
>
>
> res at gsnHistogramDiscreteBinValues  = intervals
>
> but I get this error.
>
> 0) Error: gsn_histogram: The bin values you picked are out of range. No
> plot will be drawn.
>
> (0) Error: gsn_histogram: The bin values you picked are out of range. No
> plot will be drawn.
>
> If I set the discrete values this way, I get this error.
>
>
> res at gsnHistogramDiscreteBinValues  = ispan(intervals(0),intervals(
> n_int-1),1)
>
>
> 0) Error: gsn_histogram: The bin values you picked are out of range. No
> plot will be drawn.
>
> (0) Error: gsn_histogram: The bin values you picked are out of range. No
> plot will be drawn.
>
>
>
> On Mon, Mar 19, 2018 at 6:16 PM, Mary Haley <haley at ucar.edu> wrote:
>
>> Hi Barry,
>>
>> The reason why those particular labels are directly centered under the
>> bars is because discrete values are being used. That is, the histogram is
>> counting the number of values *equal* to specific values, rather than in a
>> range of values.  You can see this from looking at this resource setting in
>> the histo_3.ncl code:
>>
>>   res at gsnHistogramDiscreteBinValues  = ispan(0,25,1)
>>
>> This will bin the values by counting the number of values exactly equal
>> to 0, exactly equal to 1, and so on up to 25.
>>
>> The labels under the tickmarks are not labelbar tickmarks, since there is
>> no labelbar in this case. These bars are drawn using filled polygons and
>> not labelbars.
>>
>> To change these labels, you need to set tickmark (tm) resources, in
>> particular, tmXBLabels. Here, I'm adding an equal sign to the front of
>> every value:
>>
>>   res at tmXBLabels           = "=" + res at gsnHistogramDiscreteBinValues
>>   res at tmXBLabelFontHeightF = 0.01
>>   res at tmXBLabelStride      = 1
>>
>>
>> Note that I also set tmXBLabelStride to 1, because in histo_3.ncl, only
>> every other bar was labeled.
>>
>> --Mary
>>
>>
>>
>> On Sun, Mar 18, 2018 at 11:09 PM, Barry Lynn <barry.h.lynn at gmail.com>
>> wrote:
>>
>>> Hi:
>>>
>>> https://www.ncl.ucar.edu/Applications/histo.shtml
>>>
>>> is  histogram where the labels appear under the bars.
>>>
>>> However, I can't seem to find the setting for this.
>>>
>>> The default appears to be between
>>>
>>> and:
>>>
>>> res at lbLabelAlignment     = "BoxCenters"
>>>
>>>
>>> is not a recognized resource,
>>>
>>> so changing this to ExteriorEdges doesn't help.
>>>
>>> Thank you,
>>>
>>> Barry
>>> --
>>> Barry H. Lynn, Ph.D
>>> Senior 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
>>> US 914 432 3108 <(914)%20432-3108>
>>>
>>> _______________________________________________
>>> 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 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
> US 914 432 3108 <(914)%20432-3108>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180319/f754503e/attachment.html>


More information about the ncl-talk mailing list