Hi

I want to draw a line between two points p1 and p2 (no problems) and then print text it along its path (facing problems). I use grconvertX() to compute the slope E.g.,

    arrows(p1.x, p1.y, p2.x., p2.y); # p2 is on right of p1
vert = grconvertX( c(p2.y, p1.y), from="user", to="inches" ); # also tried to="device"
    horz = grconvertX( c(p2.x, p1.x), from="user", to="inches" );
    srt = 180 * atan( diff(vert) / diff(horz) );
    text( p2.x, p2.y, "this line", pos=2, srt=srt );

However, the text is never exactly aligned with the line. Usually, it's a little overtilted. I also tried variously with par(c("fin","din","pin","plt")) but same kind of luck.

I was wondering if
- Is there a more appropriate way to compute the srt   parameter?
- is there some other simple function to to write text at a slope matching that of some line?

I am using R2.13.1 on a notebook running Windows 7 64bit.

Thanks
din...@milkorwater.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to