-
Notifications
You must be signed in to change notification settings - Fork 16
/
reduce.cex.Rd
52 lines (43 loc) · 1.5 KB
/
reduce.cex.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
\name{reduce.cex}
\alias{reduce.cex}
\title{reduce cex}
\description{If edges of the text are going out of the plotting
region, then decrease cex until it fits. We call \code{\link{calc.boxes}}
\code{\link{inside}}, so you should set cex before using this.}
\usage{reduce.cex(sides)}
\arguments{
\item{sides}{string: lr (left and right) or tb (top and bottom).}
}
\author{Toby Dylan Hocking}
\examples{
if(require(lars) && require(ggplot2)){
data(diabetes,package="lars",envir=environment())
X <- diabetes$x
colnames(X) <- paste(colnames(X), colnames(X))
fit <- lars(X,diabetes$y,type="lasso")
beta <- scale(coef(fit),FALSE,1/fit$normx)
arclength <- rowSums(abs(beta))
path.list <- list()
for(variable in colnames(beta)){
standardized.coef <- beta[, variable]
path.list[[variable]] <-
data.frame(step=seq_along(standardized.coef),
arclength,
variable,
standardized.coef)
}
path <- do.call(rbind, path.list)
p <- ggplot(path,aes(arclength,standardized.coef,colour=variable))+
geom_line(aes(group=variable))
## the legend isn't very helpful.
print(p)
## add direct labels at the end of the lines.
direct.label(p, "last.points")
## on my screen, some of the labels go off the end, so we can use
## this Positioning Method to reduce the text size until the labels
## are on the plot.
direct.label(p, list("last.points",reduce.cex("lr")))
## the default direct labels for lineplots are similar.
direct.label(p)
}
}