[ncl-talk] Bar Graph/Histogram plot question
Mary Haley
haley at ucar.edu
Mon Apr 24 15:34:10 MDT 2017
Hi Barry,
The gsn_histogram function takes whatever "bin" values you give it, and
counts the number of values that fall in each bin, and then draws this as a
bar.
If you don't provide any bins, then gsn_histogram will pick "nice" bins for
you.
The binning happens such that no values are binned in more than one
interval.
Try running the attached script.
In the first plot, I let gsn_histogram pick the bin intervals.
The first bin, which is from 1 to 2, will capture all values >= 1 and < 2,
the second bin counts all values >=2 and < 3 and so on. The very last bin,
9 to 10, will count all values >= 9 and <= 10.
The second plot I specifically set the bin intervals that I want.
In the third plot, instead of counting values that fall in a range, I set
an array of discrete values to explicitly count.
Hope this helps clear things up.
--Mary
On Sun, Apr 23, 2017 at 2:23 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:
> Hi:
>
> I have data specified as below.
>
> I adapted code from this page:
>
> https://www.ncl.ucar.edu/Applications/histo.shtml
>
> Example # 6.
>
> I set x = "Obs" and y = "Forecast" below.
>
> The plot I get spreads the obs and forecast data on the x axis (where the
> x axis conforms to the value of each).
>
> The y axis is labeled "Frequency."
>
> However, this is not a histogram/bar graph I am familiar with. I am not
> sure how frequency is calculated (perhaps out of the total). In any case, I
> want to plot the x axis as intervals of 0 to 100 (by 10). I want the
> y-axis to show the values in the obs/forecasts that conform to these
> intervals. (Kaleidagraph can do this easily, but that's not the point
> (obviously)).
>
> I see no such example of how to do this -- even though this is often how
> bar graphs are presented.
>
> Thank you for your suggestions.
>
> Barry
>
> z = new((/2,dimsizes(x)/),integer)
> z(0,:) = x
> z(1,:) = y
>
> Percent, Obs, Forecast
>
> 0 0.0, 0.0,
>
> 1 227.0, 212.2,
>
> 4 375.0, 176.7,
>
> 8 201.0, 141.1,
>
> 12 62.0, 143.2,
>
> 18 26.0, 327.5,
>
> 24 6.0, 199.5,
>
> 30 1.0, 50.2,
>
> 36 2.0, 9.4,
>
> 100 0.0, 4.0,
>
>
>
>
>
>
> --
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170424/53111d11/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hist_example.ncl
Type: application/octet-stream
Size: 666 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170424/53111d11/attachment.obj
More information about the ncl-talk
mailing list