From: Duncan Murdoch <murdoch_at_stats.uwo.ca>

Date: Sun 05 Feb 2006 - 08:19:59 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Feb 05 08:27:35 2006

Date: Sun 05 Feb 2006 - 08:19:59 EST

On 2/4/2006 3:50 PM, ivo welch wrote:

> [resent, plus small addition; I do not understand why gmail sent a

*> weird charset.]
**>
**> Dear R wizards:
**>
**> I would love to write a general function that matches the slope of a plotted
**> line in an xy-plot at a particular x,y location. something like
**>
**> x<- (1:10)^2; y<- 40:50;
**> plot( x,y, type="l", xlim=c(0,90) )
**> srt.at5 = text.at.current.plot.with.slope( x, y, 5);
**> text( x[5],y[5], pos=3, srt=srt.at.5);
**>
**> to do this, I first need to compute the function slope around x[5], which is
**> an easy task. alas, the harder task is that I need to scale this by the
**> plot aspect ratio and the axes. How can a function read this from the
**> current plot?
*

I haven't done this, but you can presumably work it out from the
conversions implied by the "fig", "fin", "plt", and/or "usr" values.

*>
*

> (Has someone written such a function, perhaps more embellished, to save me

*> the debugging effort?)
**>
**> Or, is there an alternative to srt, which slopes the text relative to the
**> existing scale?
**>
**> *** come to think of it, what I would really like is the ability of
**> text to 'snake' itself along the line itself. I doubt that this is
**> easily possible, but I just wanted to ask.
*

Using strsplit and strwidth you should be able to do it, but it will probably look quite ugly.

Duncan Murdoch

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Feb 05 08:27:35 2006

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:42:22 EST
*