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

Home » Public Forums » archive » Re: TEXT Function
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 Function [message #76599] Fri, 10 June 2011 06:39
Kim is currently offline  Kim
Messages: 19
Registered: January 2009
Junior Member
On Jun 9, 5:28 pm, Gray <grayliketheco...@gmail.com> wrote:
> On Jun 9, 9:41 am, Kim <kimh...@gmail.com> wrote:
>
>> Hello,
>> I am having trouble with the TEXT function when I put multiple plots
>> on the same figure (in a FOR loop).  In the following example, the
>> text is written in the same location on the first plot instead of each
>> subsequent plot.  Any advice would be greatly appreciated.
>> Thank you,
>> Kim
>
>> W = WINDOW(DIMENSIONS=[1024,1024])
>> FOR N=0,3 DO BEGIN
>>   Y = SIN((N+1)*FINDGEN(201)*!PI/25.0)
>>   P = PLOT(Y,/CURRENT,LAYOUT=[1,4,N+1])
>>   T = TEXT(0.18,0.94,'N = '+STRING(N+1),/NORMAL,TARGET=P)
>> ENDFOR
>
> The reason is that you're putting the text in with NORMAL coords set,
> so it's relative to the window.  Everything is in the same window, so
> the normal coords don't change when you change plots.  You'll need to
> change to DATA coords, I think, or figure out some algorithm to define
> your normal coord placement for each plot.  Or do it by hand.  :)

That makes sense. I thought if I specified TARGET=P that the
coordinate set would be associated with the plot and not the window.
Thank you,
Kim
Re: TEXT Function [message #76601 is a reply to message #76599] Thu, 09 June 2011 14:44 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gray writes:

> You would use XYOUTS and not CGTEXT??

Well, in this particular instance, I had to use
PLOT and not cgPlot, so it made a little more
sense to me to use XYOUTS rather than cgText.
The "problem" with Coyote Graphics (and, I suspect,
with function graphics too, is that the "objects"
have to be self-contained to work properly. With
Coyote Graphics this means setting and then restoring
system variables, which you would like to NOT be
set back if you are going to depend on them to
position the *next* graphics command.

Fortunately, the Coyote Graphics system is flexible
enough to be able to handle these somewhat contradictory
requirements. I'm already thinking about how to
overcome these difficulties in Coyote Graphics 2.0.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
Re: TEXT Function [message #76602 is a reply to message #76601] Thu, 09 June 2011 14:28 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Jun 9, 9:41 am, Kim <kimh...@gmail.com> wrote:
> Hello,
> I am having trouble with the TEXT function when I put multiple plots
> on the same figure (in a FOR loop).  In the following example, the
> text is written in the same location on the first plot instead of each
> subsequent plot.  Any advice would be greatly appreciated.
> Thank you,
> Kim
>
> W = WINDOW(DIMENSIONS=[1024,1024])
> FOR N=0,3 DO BEGIN
>   Y = SIN((N+1)*FINDGEN(201)*!PI/25.0)
>   P = PLOT(Y,/CURRENT,LAYOUT=[1,4,N+1])
>   T = TEXT(0.18,0.94,'N = '+STRING(N+1),/NORMAL,TARGET=P)
> ENDFOR

The reason is that you're putting the text in with NORMAL coords set,
so it's relative to the window. Everything is in the same window, so
the normal coords don't change when you change plots. You'll need to
change to DATA coords, I think, or figure out some algorithm to define
your normal coord placement for each plot. Or do it by hand. :)
Re: TEXT Function [message #76603 is a reply to message #76602] Thu, 09 June 2011 14:27 Go to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Jun 9, 11:00 am, David Fanning <n...@dfanning.com> wrote:
> Kim writes:
>
>> Hello,
>> I am having trouble with the TEXT function when I put multiple plots
>> on the same figure (in a FOR loop).  In the following example, the
>> text is written in the same location on the first plot instead of each
>> subsequent plot.  Any advice would be greatly appreciated.
>> Thank you,
>> Kim
>
>> W = WINDOW(DIMENSIONS=[1024,1024])
>> FOR N=0,3 DO BEGIN
>>   Y = SIN((N+1)*FINDGEN(201)*!PI/25.0)
>>   P = PLOT(Y,/CURRENT,LAYOUT=[1,4,N+1])
>>   T = TEXT(0.18,0.94,'N = '+STRING(N+1),/NORMAL,TARGET=P)
>> ENDFOR
>
> I have no idea how to do this with function graphics.
> Here is how I would do it with Coyote Graphics.
>
> ;--------------------------------------------------------
> cgWindow, WXSize=800, WYSize=800, WMULTI=[0,1,4]
> FOR N=0,3 DO BEGIN
>   Y = SIN((N+1)*FINDGEN(201)*!PI/25.0)
>   cgWindow, 'Plot', y, /LOAD, COLOR=cgColor('black'), $
>     BACKGROUND=cgColor('white')
>   cgWindow, 'XYOUTS',!X.CRange[0]+10, !Y.CRange[1]-0.5,$
>     'N = '+STRTrim(N,2), /LOAD, COLOR=cgColor('red')
> ENDFOR
> cgWindow, /EXECUTE
> ;--------------------------------------------------------
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thue. ("Perhaps thos speakest truth.")

You would use XYOUTS and not CGTEXT??
Re: TEXT Function [message #76607 is a reply to message #76603] Thu, 09 June 2011 11:00 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kim writes:

>
> Hello,
> I am having trouble with the TEXT function when I put multiple plots
> on the same figure (in a FOR loop). In the following example, the
> text is written in the same location on the first plot instead of each
> subsequent plot. Any advice would be greatly appreciated.
> Thank you,
> Kim
>
>
> W = WINDOW(DIMENSIONS=[1024,1024])
> FOR N=0,3 DO BEGIN
> Y = SIN((N+1)*FINDGEN(201)*!PI/25.0)
> P = PLOT(Y,/CURRENT,LAYOUT=[1,4,N+1])
> T = TEXT(0.18,0.94,'N = '+STRING(N+1),/NORMAL,TARGET=P)
> ENDFOR

I have no idea how to do this with function graphics.
Here is how I would do it with Coyote Graphics.

;--------------------------------------------------------
cgWindow, WXSize=800, WYSize=800, WMULTI=[0,1,4]
FOR N=0,3 DO BEGIN
Y = SIN((N+1)*FINDGEN(201)*!PI/25.0)
cgWindow, 'Plot', y, /LOAD, COLOR=cgColor('black'), $
BACKGROUND=cgColor('white')
cgWindow, 'XYOUTS',!X.CRange[0]+10, !Y.CRange[1]-0.5,$
'N = '+STRTrim(N,2), /LOAD, COLOR=cgColor('red')
ENDFOR
cgWindow, /EXECUTE
;--------------------------------------------------------


Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Find group_leader of a widget
Next Topic: Re: Connecting GPC to IDL

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

Current Time: Wed Oct 08 13:40:33 PDT 2025

Total time taken to generate the page: 0.00483 seconds