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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Histogram saga [message #48826] Mon, 22 May 2006 17:01
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JD Smith writes:

> I wonder why someone hasn't written a full purpose
> histogram plotting tool with shading and other nice features?

Probably because I have mentioned too often on this
newsgroup what a lot of grief I get over my COLORBAR
routine. And for the same reason: it sounds like a general
purpose program to do this one simple thing would be an easy
program to write, but it is MUCH harder in practice to write
something general than it is to write something specific.

I could write 10 *specific* COLORBAR programs in the
time it takes to write one general (and usually compromised)
one. HISTOGRAMS, I find, are the same way. I've flirted with
them, and my book even contains one that I've used in
various ways. But each histogram is so different, that
I've never liked any of my routines for a *general* routine.
I usually use the one I have as a pattern for the others,
tweaking as necessary.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Histogram saga [message #48827 is a reply to message #48826] Mon, 22 May 2006 15:05 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 22 May 2006 14:11:33 -0600, David Fanning wrote:

> JD Smith writes:
>
>> That's just a deficiency of the PSYM=10, and is a plotting issue (one we
>> all come across eventually). The original poster claims HISTOGRAM is
>> inventing values where there are none. I find this highly doubtful. Try
>> LOCATIONS=l and ensure your bin locations are where you think there are.
>
> I thought he was saying HISTOGRAM invented values, too, when I read the
> article initially. But he was definitely talking about "plotting", and I
> can see how you might think there was an invented value if you plotted a
> histogram. At the very least, you suspect *something* is wrong!

Ahah, right you are. I wonder why someone hasn't written a full purpose
histogram plotting tool with shading and other nice features? Maybe
somebody has... My routines which plot histograms look very, very sad
with all that half bin offsetting malarkey. It's pretty bad when the
HISTOGRAM calls themselves are easier to read and interpret than the code
to plot their results.

JD
Re: Histogram saga [message #48831 is a reply to message #48827] Mon, 22 May 2006 13:11 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JD Smith writes:

> That's just a deficiency of the PSYM=10, and is a plotting issue (one
> we all come across eventually). The original poster claims HISTOGRAM
> is inventing values where there are none. I find this highly doubtful.
> Try LOCATIONS=l and ensure your bin locations are where you think
> there are.

I thought he was saying HISTOGRAM invented values, too,
when I read the article initially. But he was definitely
talking about "plotting", and I can see how you might
think there was an invented value if you plotted a histogram.
At the very least, you suspect *something* is wrong!

But I didn't give any credibility to invented values, either.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Histogram saga [message #48832 is a reply to message #48831] Mon, 22 May 2006 12:44 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 22 May 2006 07:26:50 -0600, David Fanning wrote:

> 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:

That's just a deficiency of the PSYM=10, and is a plotting issue (one
we all come across eventually). The original poster claims HISTOGRAM
is inventing values where there are none. I find this highly doubtful.
Try LOCATIONS=l and ensure your bin locations are where you think
there are.

JD
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/
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 15:39:26 PDT 2025

Total time taken to generate the page: 0.00573 seconds