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

Home » Public Forums » archive » Re: text positioning within multiple plots
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: text positioning within multiple plots [message #54698] Tue, 10 July 2007 09:33 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
astroboy2k@gmail.com writes:

> I think the problem here is in using the /normal keyword in multiple
> plots.
>
> Doing this:
> plot,findgen(10)
> xyouts,.1,.1,char,/normal
>
> places char in the lower left hand part of the screen, regardless of
> whether you're using multiple plots or not, which is no good.

I'm not sure "no good" is how I would describe it. I think
"exactly what you want and expect" is probably a better
description. Normalized coordinates are referenced to
the *display window* and *never* to a plot.

If you wanted to use normalized coordinates, then you
should get your bearings from the ![XY].Window system
variables after each plot.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: text positioning within multiple plots [message #54703 is a reply to message #54698] Tue, 10 July 2007 09:22 Go to previous messageGo to next message
astroboy2k is currently offline  astroboy2k
Messages: 34
Registered: July 2007
Member
I think the problem here is in using the /normal keyword in multiple
plots.

Doing this:
plot,findgen(10)
xyouts,.1,.1,char,/normal

places char in the lower left hand part of the screen, regardless of
whether you're using multiple plots or not, which is no good.

I wrote the following code to overcome this problem:

Mark


;
pro
sub_xyouts,xx0,yy0,char,charsize=charsize,xdata=xdata,ydata= ydata,color=color,align=align

;xx0 and yy0 are usually normal coordinates, eg, fraction of the
current area of the plot
;setting the xdata or ydata keywords converts xx0 and yy0 from data to
normal coordinates

xx=xx0
yy=yy0

delx=!x.window(1)-!x.window(0)
dely=!y.window(1)-!y.window(0)

if keyword_set(ydata) then yy=(yy-!y.crange(0))/(!y.crange(1)-!
y.crange(0))
if keyword_set(xdata) then xx=(xx-!x.crange(0))/(!x.crange(1)-!
x.crange(0))
col=0
if keyword_set(color) then col=color

xx=!x.window(0)+xx*delx+.02*delx
yy=!y.window(0)+yy*dely+.02*dely


csize=.8
if (keyword_set(charsize)) then csize=charsize

col=0
if keyword_set(color) then col=color


aline=0.
if keyword_set(align) then aline=align
xyouts,xx,yy,char,charsize=csize,/normal,color=col,align=ali ne

return
end
Re: text positioning within multiple plots [message #54707 is a reply to message #54703] Tue, 10 July 2007 07:50 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
metachronist writes:

> May be this is already been discussed or trivial. In any case, I have
> multiple plots that go into same page, and I would like to position
> text within each of these sub windows, as they are plotted from within
> a loop, while using !p.multi.
> What is the best way to do it? For example, I have !
> p.multi=[0,2,7,0,1]. Say, I would like to put the station codes inside
> each of these 14 subwindows. I tried 'xyouts' with a bunch of
> combinations, but didn't work. I was thinking that when we use default
> data coordinates, then if we specify the location of each call to
> xyouts based on "data" specific to that window, then it should put the
> text at the correct location within that specific window. But it's
> not?!

Well, I expect this is pilot error. Exactly *when*
are you calling your XYOUTS command? If you do it
directly after you draw each plot, I think it can't
help but go in the right place. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: text positioning within multiple plots [message #54708 is a reply to message #54707] Tue, 10 July 2007 07:50 Go to previous messageGo to next message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Jul 10, 10:38 am, metachronist <rkombi...@gmail.com> wrote:
> May be this is already been discussed or trivial. In any case, I have
> multiple plots that go into same page, and I would like to position
> text within each of these sub windows, as they are plotted from within
> a loop, while using !p.multi.
> What is the best way to do it? For example, I have !
> p.multi=[0,2,7,0,1]. Say, I would like to put the station codes inside
> each of these 14 subwindows. I tried 'xyouts' with a bunch of
> combinations, but didn't work. I was thinking that when we use default
> data coordinates, then if we specify the location of each call to
> xyouts based on "data" specific to that window, then it should put the
> text at the correct location within that specific window. But it's
> not?! :-( Appreciate any help.
> TIA,
> /rk

xyouts works exactly the same with !P.MULTI set as it does without
it. For instance:

!P.MULTI = [0,1,2]
plot,[0,1],[0,1]
xyouts,.05,.9,'a line'
plot,[5,10],[5,10]
xyouts,5.1,9,'another line'

That should make two plots with a line of text in each. You do have
to make sure that the xyouts call comes after the plot you want it on,
and before any others. Otherwise it will output to the wrong plot.
I'm not sure why what you're trying isn't working. Maybe I've
misunderstood your problem? Can you give some example code that isn't
cooperating?
Re: text positioning within multiple plots [message #54837 is a reply to message #54707] Tue, 10 July 2007 19:52 Go to previous message
rkombiyil is currently offline  rkombiyil
Messages: 59
Registered: March 2006
Member
On Jul 10, 11:50 pm, David Fanning <n...@dfanning.com> wrote:

> Well, I expect this is pilot error. Exactly *when*
> are you calling your XYOUTS command? If you do it
> directly after you draw each plot, I think it can't
> help but go in the right place. :-)

Thank you gentlemen :-) for taking time off to reply.
It sure was pilot error, for two reasons:

1. I wanted to look at particular window in the time series and in my
call to xyouts for specifying "Y" position, I used "max" of the whole
range instead of the required window.

2. The range in Y varies from station to station, so I just had to
figure out an optimum way for the Y position.
Problem solved after the morning cup of coffee :-)
~rk
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: MOD43B3 Col.4 Processing. unexpected error message. why?
Next Topic: storing string array into HDF

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

Current Time: Wed Oct 08 13:53:26 PDT 2025

Total time taken to generate the page: 0.00610 seconds