[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: draw text parallel to a sloping line*From*: davidf(at)dfanning.com (David Fanning)*Date*: Sat, 4 Mar 2000 17:43:03 -0700*Newsgroups*: comp.lang.idl-pvwave*Organization*: Fanning Software Consulting*References*: <38C1644C.FB280C52@risoe.dk> <38c179f7.0@cfanews.harvard.edu>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:18786

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,/TO_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

**References**:**draw text parallel to a sloping line***From:*Kristian Kjaer

**Re: draw text parallel to a sloping line***From:*Vinay L. Kashyap

- Prev by Date:
**Re: draw text parallel to a sloping line** - Next by Date:
**Re: xyouts character size to scale with the size of the plot window** - Prev by thread:
**Re: draw text parallel to a sloping line** - Next by thread:
**xyouts character size to scale with the size of the plot window** - Index(es):