comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Very strange problem in IDL histogram, A bug???
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Very strange problem in IDL histogram, A bug??? [message #76678] Thu, 23 June 2011 10:09 Go to next message
Poonam Chandra is currently offline  Poonam Chandra
Messages: 12
Registered: June 2011
Junior Member
Hi,
My data distribution looks like this:

Range No.
0-50 0
50-100 8
100-150 14
150-200 18
200-250 8
250-300 8
300-350 5
350-400 2
400-600 17
600-800 4
800-1000 6
1000-2000 2

With the help of Jeremy in a previous discussion, this is how I am
proceeding:

data = [50+randomu(seed,8)*50, 100+randomu(seed,14)*50,
150+randomu(seed,18)*50, $
200+randomu(seed,8)*50, 250+randomu(seed,8)*50, 300+randomu(seed,
5)*50, 350+randomu(seed,2)*50, $ 400+randomu(seed,17)*200,
600+randomu(seed,4)*200, 800+randomu(seed,6)*200, $
1000+randomu(seed,2)*1000]

bin_edges = [0,50,100,150,200,250,300,350,400,600,800,1000,2000]
nbins = n_elements(bin_edges)-1
data_bins = value_locate(bin_edges, data)
labelnums = rebin(1 # bin_edges, 2, nbins+1, /sample)
labels = string(labelnums[1:2*nbins], format='(%"%0d - %0d")')

cghistoplot, data_bins, xrange=[0,nbins], xticks=nbins-1, $
xtickv=0.5+indgen(nbins), xtickname=labels, /window

And in the plot window, this is what the final distribution is
looking:
0-75 0
75-175 22
175-275 26
275-375 13
375-700 2
700-1050 0
1050-2000 2

This is totally crazy. How did the IDL get this distribution for the
histogram?
I backtracked the problem and I see that as long as I define my data
has 7
ranges (i.e. 0-50, 50-100, 100-150, 150-200, 200-250, 250-300,
300-350, 350-400),
everything is fine but the moment I add the next range i.e. 400-600,
it totally goofs up.
Any idea whats going on? Is it any bug in histogram? If I have your
email address, I can actually
send the full program and the final plots for you to have a look at.
Re: Very strange problem in IDL histogram, A bug??? [message #76741 is a reply to message #76678] Mon, 27 June 2011 08:18 Go to previous message
Poonam Chandra is currently offline  Poonam Chandra
Messages: 12
Registered: June 2011
Junior Member
On Jun 25, 2:49 pm, Poonam <poonam.chan...@gmail.com> wrote:
> On Jun 24, 4:30 pm, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>> By default, cghistoplot uses an adaptive algorithm to decide on the binsizes. To force it to a bin size of 1 (which is what you want), use binsize=1 in the cghistoplot call.
>
Thanks Jeremy, it did work great.
Poonam
Re: Very strange problem in IDL histogram, A bug??? [message #76747 is a reply to message #76678] Sat, 25 June 2011 11:49 Go to previous message
Poonam is currently offline  Poonam
Messages: 7
Registered: June 2011
Junior Member
On Jun 24, 4:30 pm, Jeremy Bailin <astroco...@gmail.com> wrote:
> By default, cghistoplot uses an adaptive algorithm to decide on the binsizes. To force it to a bin size of 1 (which is what you want), use binsize=1 in the cghistoplot call.
>
> -Jeremy.

Thanks Jeremy. I don't have IDL at home. Will try on Monday once I
reach office.

Poonam
Re: Very strange problem in IDL histogram, A bug??? [message #76755 is a reply to message #76678] Fri, 24 June 2011 13:30 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
By default, cghistoplot uses an adaptive algorithm to decide on the binsizes. To force it to a bin size of 1 (which is what you want), use binsize=1 in the cghistoplot call.

-Jeremy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Formatted printf output
Next Topic: Re: Compilation Error: Procedure header must appear first and only once

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:48:35 PDT 2025

Total time taken to generate the page: 0.00602 seconds