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

Home » Public Forums » archive » Re: Histogram shift
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 shift [message #42714 is a reply to message #42712] Mon, 21 February 2005 17:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael Wallace writes:

> Okay, another object graphics question for everyone. Is there an easy
> way to shift a histogram over such that the bars are left justified with
> the data point rather than having the bars centered on the data point?
>
> I realize that I could shift the data itself and then draw the
> histogram, but there's a voice in the back of my mind that tells me
> "you're gonna shoot yourself in the foot, kid." Is there some other way
> to left justify the plot?

I thought the whole point of object graphics was that
you could do anything you wanted to do if you were
willing to spend enough time with inadequate documentation
to do it?

Cheers,

David

P.S. I don't have any ideas about how to do this in
object graphics. About a fourth of my book is about
how to do it in direct graphics. Presumably some of
those techniques could be extended to object graphics.

Here is the relevant part of the code:

; 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 the histogram of the display image. Axes first.

Plot, binsToPlot, histdataToPlot, $
Background=backcolor, $
Charsize=thisCharsize, $
Color=axiscolor,
Max_Value=max_value, $
NoData=1, $
Position=histoPos, $
Title='Image Histogram', $
XRange=xrange, $
XStyle=1, $
XTickformat='(I6)', $
XTitle='Image Value', $
YMinor=1, $
YRange=[0,max_value], $
YStyle=1, $
YTickformat='(I6)', $
YTitle='Pixel Density', $
_Extra=extra

; Overplot the histogram data in the data color.

OPlot, 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

--
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: Maximze a minimize GUI
Next Topic: Re: /YNOZERO

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

Current Time: Tue Dec 02 05:22:00 PST 2025

Total time taken to generate the page: 3.35437 seconds