Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44664 is a reply to message #44663] |
Fri, 08 July 2005 02:22   |
Ben Panter
Messages: 102 Registered: July 2003
|
Senior Member |
|
|
liko2@o2.pl wrote:
> I cant change data because Its very important to me to see how much
> space ist between each bar... I should use PLOTS then, but Im beginer
> in IDL...
>
OK. I'm pretty sure there are more elegant ways to do this, but for for
a five minute coffee break solution try this:
IDL> ;make some sample data longer than 80 elements
IDL> x=findgen(80)
IDL> y=hanning(80)
% Compiled module: HANNING.
IDL> ;Make the initial plot
IDL> plot, x, y, psym=10
IDL> ;find midpoints for x ordinate of line
IDL> midpt=x[0:78]+0.5*(x[1:79]-x[0:78])
IDL> ;draw the lines
IDL> for i=0,78 do plots, [midpt[i],midpt[i]], $
IDL> [!y.crange[0],max([y[i],y[i+1]])]
Where $ indicates the expression rolls over to the next line and
!y.crange is the bottom of the y-axis. The max(...) bit makes sure that
you get the full height of the bin.
To make your code flexible, change the 78,79,80 to variations of
num_bars=N_ELEMENTS(x)
HTH,
Ben
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ben Panter, Garching, Germany
email via www.benpanter.co.uk
|
|
|