[ncl-talk] Question about a Histogram Plot

Mary Haley haley at ucar.edu
Mon Nov 20 09:56:01 MST 2017


Barry,

I've updated the histogram examples page to more clearly state how to get
the exact intervals you want in a histogram. See example histo_2.ncl (and
others) at:

http://www.ncl.ucar.edu/Applications/histo.shtml

Since you didn't specify the actual bins you wanted gsn_histogram to use,
NCL chose a default of these bins:

(  0, 2.5,  5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5 )

You can see these values by printing the value returned from gsn_histogram
and looking at the BinLocs attribute:

  plot = gsn_histogram(wks,x,res)
  print(plot)        ; this prints everything attached to plot
                              print(plot at BinLocs)  ; the actual bin ranges
used
To set the bin values yourself:

  res at gsnHistogramBinIntervals = int_radar


BTW, you want to stay away from do loops as much as possible.  I'm not sure
what these loops are supposed to be calculating:

  obs_x = new(dims_num_o-1,float)
  mod_x = new(dims_num_m-1,float)
  ii_int = 0
  do i_int = 1,dims_num_o-1
  obs_x(ii_int) = num_o(i_int)
  ii_int = ii_int + 1
  end do
  ii_int = 0
  do i_int = 1,dims_num_m-1
  mod_x(ii_int) = num_m(i_int)
  ii_int = ii_int + 1
  end do

but this can be rewritten as two lines of code:

  obs_x = num_o(1:)
  mod_x = num_m(1:)

--Mary




On Mon, Nov 20, 2017 at 6:01 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hi:
>
> I can get the labels to display correctly if I use:
>
> res at tmXBLabels = int_radar(::3)
>
>
> However, the histogram program is amalgamating the smaller bins into 10
> sized default bins.
>
>
> I would hope that there is a way to explicitly tell the histogram program
> to use all the interval data (23 intervals.
>
>
> I tried setting:
>
>
> res at tmXBMode        = "Manual"
>
> and creating manual tick marks, but then my histogram labels go only from
> 0 to 1.
>
>
> As below.
>
>
>  rad_inc = 3./(int_radar(dimsizes(int_radar)-1)+10)
>
>   print("rad_inc  = " +rad_inc)
>
>   new_ticks = new(dimsizes(int_radar),float)
>
>   new_ticks(0)= 0
>
>   do inc = 1,dimsizes(int_radar)-1,1
>
>    new_ticks(inc) = new_ticks(inc-1)+rad_inc
>
>   end do
>
>   print("new_ticks = " + new_ticks)
>
>   res at tmXBValues := new_ticks
>
>   res at tmXBLabels := int_radar
>
> On Sun, Nov 19, 2017 at 9:21 PM, Barry Lynn <barry.h.lynn at gmail.com>
> wrote:
>
>> Hi:
>>
>> I am having trouble figuring out why my histo.ncl program won't plot data
>> beyond value (x-axis) of 15.  This is really dbz data, so the range is
>> correct: -9 to 60.
>>
>> I also checked that the labels are present in:
>>
>> res at tmXBLabels = int_radar
>>
>>
>> and the data dimensions are correct (23 elements).
>>
>> However, I don't see any data (and any labels 18-60) indicating that the
>> data has all been displayed.
>>
>> 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>
>>
>
>
>
> --
> 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/20171120/76a7f086/attachment.html>


More information about the ncl-talk mailing list