# Re: histogram problem

Date: Mon Feb 25 2013 - 07:03:14 MST

Hi Mary et al.
yes, thatīs correct, I needed to use gsnHistogramBinIntervals. The
following gives the correct histograms for the distribution of convective
events by month.

thanks,
Dave

begin
ncol1 = 1
nlvl = 278

seasonal_data =
day = seasonal_data(:,0)

wks = gsn_open_wks("pdf", "Time_local_hour_event_histogram")
; Make histogram plot but donīt plot it yet
res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnHistogramClassIntervals(/1,31,59,90,120,151,181,212,243,273,304,334,
365/)
plot = gsn_histogram(wks,day,res)

delete(res@gsnDraw)
delete(res@gsnFrame)

res@tmXBMode = "Explicit" ; Define tick mark labels.
res@tmXBValues = plot@MidBarLocs
res@tmXBLabels = (/"J","F","M","A","M","J","J","A","S","O","N","D"/)
plot=gsn_histogram(wks,day,res) ; create histogram

draw(plot)
end

On Sun, Feb 24, 2013 at 11:49 PM, Mary Haley <haley@ucar.edu> wrote:

> Hi Dave,
>
> As far as I can tell, the plot is correct. By using
> gsnHistogramDiscreteBinValues, you are telling the histogram program to
> count the number of values *exactly* equal to 30, 60, ..., 360. All other
> values that are not equal to these values will not be counted.
>
> If you write a do loop and count the number "day" values that are equal to
> each of your bin values:
>
> do i=0,dimsizes(res@gsnHistogramDiscreteBinValues)-1
> print("num values = " + res@gsnHistogramDiscreteBinValues(i) + \
> " is " + num(day.eq.res@gsnHistogramDiscreteBinValues(i)))
> end do
>
> you get:
>
> (0) num values = 30 is 1
> (0) num values = 60 is 1
> (0) num values = 90 is 0
> (0) num values = 120 is 1
> (0) num values = 150 is 0
> (0) num values = 180 is 0
> (0) num values = 210 is 0
> (0) num values = 240 is 0
> (0) num values = 270 is 0
> (0) num values = 300 is 1
> (0) num values = 330 is 2
> (0) num values = 360 is 1
>
> The histogram plot is showing exactly the above values.
>
> What were you expecting to get? Did you perhaps mean to use
> gsnHistogramBinIntervals?
>
> --Mary
>
>
> On Feb 24, 2013, at 8:28 PM, David Adams wrote:
>
> > Hi all,
> > I am try to create histogram of number of convective events for each
> month of the year.
> > The input file is simply the integer value of the day of the year for
> the reported convective event. However, the plots are incorrect.
> > My version of ncl is NCAR Command Language Version 6.0.0
> > Any suggestions?
> >
> > thanks,
> >
> > ; test.ncl
> > ; This ncl program reads in integer days of the year
> > ; for for convective events to make a
> > ; histogram of monthly convective events.
> >
> >
> > begin
> > ncol1 = 1
> > nlvl = 278
> >
> > seasonal_data =
> > day = seasonal_data(:,0)
> >
> > wks = gsn_open_wks("pdf", "Time_local_hour_event_histogram")
> >
> > res = True
> > res@gsnDraw = False
> > res@gsnFrame = False
> >
> > res@gsnHistogramDiscreteBinValues = ispan(30,360,30)
> >
> > plot = gsn_histogram(wks,day,res)
> >
> > delete(res@gsnDraw)
> > delete(res@gsnFrame)
> >
> > res@tmXBMode = "Explicit" ; Define tick mark labels.
> > res@tmXBValues = plot@MidBarLocs
> > res@tmXBLabels = (/"J","F","M","A","M","J","J","A","S","O","N","D"/)
> > plot=gsn_histogram(wks,day,res) ; create histogram
> >
> > draw(plot)
> > end
> > ~
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> <Seasonal_dates_convective_events.dat><test.ncl>_______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 25 07:03:35 2013

This archive was generated by hypermail 2.1.8 : Thu Feb 28 2013 - 14:47:31 MST