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

Home » Public Forums » archive » Re: Histogram saga
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Histogram saga [message #48837 is a reply to message #48832] Mon, 22 May 2006 06:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Daelomin writes:

> I just looked at all the archives with histogram related problems..
>
> I am quite surprised to see that it's not fixed in 6.2. I recently had
> a problem with my data: I plot 86140 points of data that range from
> [8,75] but somehow IDL creates bogus values between 0 & 8 !!
>
> If I include another point in the array (say array2=fltarr(86141) &
> array2[0:86139]=array1[*]) which value is 0, I then get the proper
> histogram I would have expected. Namely it has a flat line between 0 &
> 8 and picks up at the minimum...
>
> I just find this really really weird...

Well, we'll add it to the list... :-)

Pretty much everyone, by now, has learned how to fudge the HISTOGRAM
output to get something that looks more like a histogram plot.
Here is how I do it:

; ************************************************************ *******
; Calculate the histogram.

histdata = Histogram(image, Binsize=binsize, Max=Max(image), $
Min=Min(image))

; Have to fudge the bins and histdata variables to get the
; histogram plot to make sense.

npts = N_Elements(histdata)
halfbinsize = binsize / 2.0
bins = Findgen(N_Elements(histdata)) * binsize + Min(image)
binsToPlot = [bins[0], bins + halfbinsize, bins[npts-1] + binsize]
histdataToPlot = [histdata[0], histdata, histdata[npts-1]]
xrange = [Min(binsToPlot), Max(binsToPlot)]

Plot, binsToPlot, histdataToPlot, PSym=10, Color=dataColor

; Make histogram boxes by drawing lines in data color.

FOR j=1L,N_Elements(bins)-2 DO BEGIN
PlotS, [bins[j], bins[j]], [!Y.CRange[0], histdata[j] < max_value], $
Color=dataColor
ENDFOR
; ************************************************************ *******

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Create new arrays from series of subsequent integers in an existing array
Next Topic: Using WIDGET_ACTIVEX to create a Socket server

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

Current Time: Fri Oct 10 01:59:47 PDT 2025

Total time taken to generate the page: 1.83816 seconds