Re: TEXT Function [message #76603 is a reply to message #76602] |
Thu, 09 June 2011 14:27   |
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??
|
|
|