Re: How to add values over bars which I plotted? [message #42064] |
Fri, 17 December 2004 15:07 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> By examining the program, I could see the information
> I needed was in the variable "ticks", so I just created a TICKS
> keyword on BAR_PLOT:
>
> Pro Bar_Plot, data, ...., TICKS=ticks
Whoops! It was "tickv" and not "ticks".
Pro Bar_Plot, data, ..., TICKV=tickv
The code I sent was right. The explanation was bogus. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: How to add values over bars which I plotted? [message #42065 is a reply to message #42064] |
Fri, 17 December 2004 15:05  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Hang Gao writes:
> I plotted 12 bars by using bar_plot.pro. Now, what I want to do is to
> add the 12 individual values over the top of 12 bars, which I often
> did in EXCEL. I tried to use xyouts procedure, but I was not sure
> about the x-positions where I suppose to add my vaules. How to know
> the exact x positions where IDL added 12 barnames automaticly? A
> further question: how to determine the distance between 2 y axises?
>
> For example, I bar_plotted: indgen(12). now I want to add the value
> [0,1,...11]
> over the 12 bars I plotted. Then how to do it?
This turned out to be a little harder than I thought
it should have been. :-)
I had to add a keyword to BAR_PLOT to get it to work, since
I need to know where the program drew the bars and it wouldn't
tell me. By examining the program, I could see the information
I needed was in the variable "ticks", so I just created a TICKS
keyword on BAR_PLOT:
Pro Bar_Plot, data, ...., TICKS=ticks
Then, I got the labels on like this:
data = indgen(12) + 2
x = indgen(12) + 0.5
Loadct, 5, NColors=13
bar_plot, data, Colors=Indgen(12)+1, tickv=tickv
skosh = (!Y.CRange[1] - !Y.CRange[0]) / 40.
FOR j=0,N_Elements(data)-1 DO $
XYOUTS, tickv[j], data[j]+skosh, Align=0.5, $
StrTrim(data[j],2),/Data
The "skosh" variable would probably be expressed in normalized
coordinates, then converted to DATA coordinates with Coord_Convert
if I were doing this for real. :-)
Cheers,
David
P.S. While you are adding keywords, this program could use
a POSITION keyword, too.
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|