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

Home » Public Forums » archive » Re: draw text parallel to a sloping line
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: draw text parallel to a sloping line [message #19193] Sat, 04 March 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Vinay L. Kashyap (kashyap@head-cfa.harvard.edu) writes:

> It doesn't work because >orientation< in XYOUTS does not know
> anything about the previous PLOT and the data ranges in the
> plot. Do the following:
>
> X = 24.5259 & Y = 16789.1 & Slope = -1763.03 ; data coordinates
> dX=2.2 & plot, [X-dX,X+dX], Y+[-dX,dX]*Slope
> ;{convert slope from data to device coordinates
> DATA_XY=convert_coord(X+DX*[-1,1],Y+DX*SLOPE*[-1,1],/DATA,/T O_DEVICE)
> DATA_DY=DATA_XY(1,1)-DATA_XY(1,0) & DATA_DX=DATA_XY(0,1)-DATA_XY(0,0)
> O_angle=atan(DATA_DY,DATA_DX)*!radeg
> ;end changes}
> xyouts,X,Y,'A_String_Parallel_To_A_Line',align=0.5,orient=O_ angle

Well, the solution is correct. But I think the explanation
could use a little work. :-)

It is not that XYOUTS doesn't "know anything" about the previous
PLOT. It certainly does know, by virtue of the !X.S and !Y.S
scaling parameters that get set by the PLOT command. Rather,
it is not the angle in data coordinate space we want here. It
is the angle of the text on the display. And you are correct
that we have to make the conversion from data space to
device space in order to properly calculate that angle.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Previous Topic: Getting rid of loops
Next Topic: xyouts character size to scale with the size of the plot window

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

Current Time: Fri Oct 10 12:02:36 PDT 2025

Total time taken to generate the page: 1.04040 seconds