Hi Also see the xinch() and yinch() functions.
Paul On 20/07/2010 10:44 a.m., Peter Ehlers wrote:
Michael, I have a very old version of some brace functions somewhere. I never did combine them into a single function, so there's one each for left/right/up/down braces. (I used them in teaching regression to show resids and formulae.) If you're interested, I'll dig 'em up and send them. Otherwise, I think you can make your inherited code work with something like Usr<- par('usr') Pin<- par('pin') dux<- Usr[2] - Usr[1] duy<- Usr[4] - Usr[3] uin<- c(dux,duy)/Pin to replace uin<- par("uin") But you'll also have to fiddle with atan() -Peter Ehlers On 2010-07-19 9:20, Michael Friendly wrote:I inherited a function written either for an older version of R or SPlus to draw a brace, "{", in a graph. It uses par("uin") to determine the scaling of the quarter circles that make up segments of the brace, but that setting doesn't exist in current R. I'm guessing that, in the function below, ux, uy can be defined from par("usr") and par("pin"), but maybe someone remembers what par("uin") was supposed to refer to. brace<- function (x1 = 0, y1 = 0, x2 = 0, y2 = 1, right = TRUE, rad = 0.2) { uin<- par("uin") ux<- uin[1] uy<- uin[2] dx<- x2 - x1 dy<- y2 - y1 alpha<- atan(ux * dx, uy * dy) scale<- sqrt((ux * dx)^2 + (uy * dy)^2) if (scale> 5 * rad) rad<- rad/scale qcirc<- cbind(cos((0:10) * pi/20), sin((0:10) * pi/20)) qcircr<- cbind(cos((10:0) * pi/20), sin((10:0) * pi/20)) rot<- function(theta) t(cbind(c(cos(theta), sin(theta)), c(-sin(theta), cos(theta)))) seg1<- t(t(rad * qcirc %*% rot(-pi/2)) + c(0, rad)) seg4<- t(t(rad * qcirc) + c(0, 1 - rad)) seg3<- t(t((rad * qcircr) %*% rot(pi)) + c(2 * rad, 0.5 + rad)) seg2<- t(t((rad * qcircr) %*% rot(pi/2)) + c(2 * rad, 0.5 - rad)) bra<- rbind(seg1, seg2, seg3, seg4) if (!right) bra<- bra %*% diag(c(-1, 1)) bra<- scale * bra %*% rot(-alpha) bra<- bra %*% diag(c(1/ux, 1/uy)) bra<- t(t(bra) + c(x1, y1)) bra }______________________________________________ [email protected] 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.
-- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [email protected] http://www.stat.auckland.ac.nz/~paul/ ______________________________________________ [email protected] 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.

