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

Home » Public Forums » archive » Re: BAR_PLOT restricted to 60 element ARRAY??
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: BAR_PLOT restricted to 60 element ARRAY?? [message #44660] Fri, 08 July 2005 05:53 Go to next message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
liko2@o2.pl wrote:
> IT WORKS! :) But.... :P When the first bar >0 it isnt proprly
> drawn...Why?

Glad it works for you. Try adapting the program to include the padding I
mentioned earlier in the thread - that will sort out the first and last
bars. psym=10 only works in the plot range (ie. between the data
points). You want to extend that range to include the edges of the first
and last bars (which are an extrapolation, which is why you do the padding).

You'll also run into problems if you ever have -ve data, but I'll let
you work that one out:)

Ben


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ben Panter, Garching, Germany
email via www.benpanter.co.uk
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44661 is a reply to message #44660] Fri, 08 July 2005 05:26 Go to previous messageGo to next message
liko2@o2.pl is currently offline  liko2@o2.pl
Messages: 15
Registered: July 2005
Junior Member
IT WORKS! :) But.... :P When the first bar >0 it isnt proprly
drawn...Why?
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44663 is a reply to message #44661] Fri, 08 July 2005 04:11 Go to previous messageGo to next message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
liko2@o2.pl wrote:
> Did you try this wit array containing several exacly the same values?It
> still creates one bar for this case...

We may be talking at cross purposes, but in my tests it didn't. I can
see I was a little too cryptic with n_elements. See the program below
for what I meant.

Save and compile the program at the end of this message, and with the
same x and y as before try this:

IDL> bp_plot_barchart, x,y, title='fred'
IDL> y[10:20]=0.6
IDL> bp_plot_barchart, x,y, title='fred'

which certainly draws lines between the 11 bars of the same height.

PROGRAM:

PRO bp_plot_barchart, x, y, _extra=e

;Make the initial plot

num_bar=n_elements(x)

plot, x, y, psym=10, _extra=e

;find midpoints for x ordinate of line

midpt=x[0:num_bar-2]+0.5*(x[1:num_bar-1]-x[0:num_bar-2])

;draw the lines

for i=0,num_bar-2 do plots, [midpt[i],midpt[i]], $
[!y.crange[0],max([y[i],y[i+1]])]

END


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ben Panter, Garching, Germany
email via www.benpanter.co.uk
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44664 is a reply to message #44663] Fri, 08 July 2005 02:22 Go to previous messageGo to next message
Ben Panter is currently offline  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
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44666 is a reply to message #44664] Fri, 08 July 2005 01:02 Go to previous messageGo to next message
liko2@o2.pl is currently offline  liko2@o2.pl
Messages: 15
Registered: July 2005
Junior Member
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...
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44678 is a reply to message #44666] Thu, 07 July 2005 07:52 Go to previous messageGo to next message
Benjamin Luethi is currently offline  Benjamin Luethi
Messages: 22
Registered: December 2004
Junior Member
another possibility:

1. plot, data, psym=10

2. set every second element equal to 0 (data[0:*:2]=0)

3. oplot, data, psym=10



On Thu, 07 Jul 2005 16:15:16 +0200, liko2@o2.pl <liko2@o2.pl> wrote:

> Yghh...Turned out that histogram isnt good option, because for 2 exacly
> the same numbers beside each other it creates one, wider bar and I need
> two of them in such case(each value must be representated by one
> bar)...Any other suggestions?
>



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
------------ And now a word from our sponsor ------------------
Do your users want the best web-email gateway? Don't let your
customers drift off to free webmail services install your own
web gateway!
-- See http://netwinsite.com/sponsor/sponsor_webmail.htm ----
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44679 is a reply to message #44678] Thu, 07 July 2005 07:51 Go to previous messageGo to next message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
liko2@o2.pl wrote:
> psym=10 is a histogram option for PLOT what I have mentioned about...It
> doesnt work for two or more values which are the same and come one
> after another...
>

Yes, I meant that that is an easy way to get the overall shape of the
line, then you can put in vertical lines using plots (not plot!) to draw
lines which distinguish the bars.

If you don't mind not having the bars next to each other you could also
do the padding operation I mentioned before to put a zero between each
bar - something like:

x=[1,2,3,4,5]
y=[3,4,5,5,2]

new_x=[0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5]
new_y=[0,3,0,4,0,5,0,5,0,5,0,2,0]

plot, new_x, new_y, psym=10, yr=[0,6]

HTH,

Ben

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ben Panter, Garching, Germany
email via www.benpanter.co.uk
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44680 is a reply to message #44679] Thu, 07 July 2005 07:48 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
This restriction is not specific to bar_plot, it is a restriction to the
xtickname keyword passed to the plot command. I am not sure, how more than
60 ticks on the x axis can be presented in a readable form? I ususally use
about 5. You will have toi write your own code using plots to drawn your
bars and xyouts to label them.

Haje


"liko" <liko2@o2.pl> wrote in message
news:ce3909d8.0507060507.6b37b543@posting.google.com...
> How to make barplot for [43,273] array? when Im using BAR_PLOT it
> displays error:
> c:\1\1.eps
> % Keyword array parameter XTICKNAME must have from 1 to 60 elements.
> % Execution halted at: BAR_PLOT 242
> C:\RSI\IDL61\lib\bar_plot.pro
> % $MAIN$ 56 D:\Egs\working_4.pro
>
>
> What is wrong?How can I make barplot of array or vector grater than 60
> elements?PLOT function doesnt have this problem...
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44681 is a reply to message #44680] Thu, 07 July 2005 07:31 Go to previous messageGo to next message
liko2@o2.pl is currently offline  liko2@o2.pl
Messages: 15
Registered: July 2005
Junior Member
psym=10 is a histogram option for PLOT what I have mentioned about...It
doesnt work for two or more values which are the same and come one
after another...
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44682 is a reply to message #44681] Thu, 07 July 2005 07:20 Go to previous messageGo to next message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
liko2@o2.pl wrote:
> Yghh...Turned out that histogram isnt good option, because for 2 exacly
> the same numbers beside each other it creates one, wider bar and I need
> two of them in such case(each value must be representated by one
> bar)...Any other suggestions?

In addition to the polyfill routine mentioned before, you can use plots
to draw lines.

Use

plot, .... , psym=10

to draw the plot, then run a for loop on plots to draw the lines between
bins. You could probably do something a bit more efficient than a for
loop with shift and rebin if you had time on your hands.



--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ben Panter, Garching, Germany
email via www.benpanter.co.uk
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44683 is a reply to message #44682] Thu, 07 July 2005 07:15 Go to previous messageGo to next message
liko2@o2.pl is currently offline  liko2@o2.pl
Messages: 15
Registered: July 2005
Junior Member
Yghh...Turned out that histogram isnt good option, because for 2 exacly
the same numbers beside each other it creates one, wider bar and I need
two of them in such case(each value must be representated by one
bar)...Any other suggestions?
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44686 is a reply to message #44683] Thu, 07 July 2005 02:26 Go to previous messageGo to next message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
liko2@o2.pl wrote:
> Thank You, that solved the problem :)
>
> Can I set colors for this plot?
>

for the line, use the standard color= keyword for the plot statement. If
this gives you unexpected results then I would read David's website at
http://www.dfanning.com

As far as I know, to get filled bars you need to use the polyfill
procedure. In order to make the first and last "bars" full width, you
can pad the x and y arrays:

x=[1,2,3,4,5,6]
y=[2,3,4,2,4,2]

x_pad=[0,x,7]
y_pad=[0,y,0]

plot, x_pad, y_pad, xstyle=1, psym=10

HTH,

Ben

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ben Panter, Garching, Germany
email via www.benpanter.co.uk
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44688 is a reply to message #44686] Thu, 07 July 2005 00:27 Go to previous messageGo to next message
liko2@o2.pl is currently offline  liko2@o2.pl
Messages: 15
Registered: July 2005
Junior Member
Thank You, that solved the problem :)

Can I set colors for this plot?
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44696 is a reply to message #44688] Wed, 06 July 2005 06:52 Go to previous messageGo to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
The bar_plot procedure is attempting to label every bar in your plot.
There is a maximum limit (60) to the number of labels you can show for
an axis.

Might I suggest using the histogram mode of the plot procedure instead?
plot, some_data, PSYM = 10

-Mike

liko wrote:
> How to make barplot for [43,273] array? when Im using BAR_PLOT it
> displays error:
> c:\1\1.eps
> % Keyword array parameter XTICKNAME must have from 1 to 60 elements.
> % Execution halted at: BAR_PLOT 242
> C:\RSI\IDL61\lib\bar_plot.pro
> % $MAIN$ 56 D:\Egs\working_4.pro
>
>
> What is wrong?How can I make barplot of array or vector grater than 60
> elements?PLOT function doesnt have this problem...
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44745 is a reply to message #44680] Sun, 10 July 2005 23:29 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Haje Korth wrote:
> This restriction is not specific to bar_plot, it is a restriction to the
> xtickname keyword passed to the plot command. I am not sure, how more than
> 60 ticks on the x axis can be presented in a readable form? I ususally use
> about 5. You will have toi write your own code using plots to drawn your
> bars and xyouts to label them.
>
> Haje

You should have a look into our library for bar_plot2. I have removed
this restriction and have added a lot of features.

; 2003-09-10 : size restriction of 60 bars removed

Based on this there was an addon for our plotlib written too.

cheers

Reimar
>
>
> "liko" <liko2@o2.pl> wrote in message
> news:ce3909d8.0507060507.6b37b543@posting.google.com...
>
>> How to make barplot for [43,273] array? when Im using BAR_PLOT it
>> displays error:
>> c:\1\1.eps
>> % Keyword array parameter XTICKNAME must have from 1 to 60 elements.
>> % Execution halted at: BAR_PLOT 242
>> C:\RSI\IDL61\lib\bar_plot.pro
>> % $MAIN$ 56 D:\Egs\working_4.pro
>>
>>
>> What is wrong?How can I make barplot of array or vector grater than 60
>> elements?PLOT function doesnt have this problem...
>
>
>



--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
Re: BAR_PLOT restricted to 60 element ARRAY?? [message #44797 is a reply to message #44660] Wed, 13 July 2005 02:42 Go to previous message
liko2@o2.pl is currently offline  liko2@o2.pl
Messages: 15
Registered: July 2005
Junior Member
Another question concerning PLOT: how can I add a albels for each bar
(or peak)? Im not using bar_plot.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: shading in contour plots
Next Topic: Re: Windows IDL DLM with Cygwin

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

Current Time: Wed Oct 08 15:47:55 PDT 2025

Total time taken to generate the page: 0.00556 seconds