| 23048 |
ripley |
1 |
#### Regression tests for GRAPHICS & PLOTS
|
|
|
2 |
|
| 23074 |
ripley |
3 |
postscript("reg-plot.ps", paper="a4", horizontal=TRUE,
|
|
|
4 |
encoding ="ISOLatin1.enc")
|
| 23048 |
ripley |
5 |
## since we supply the font metrics, the results depend only on
|
| 23074 |
ripley |
6 |
## the encoding used: Windows is different from Unix by default.
|
| 23048 |
ripley |
7 |
|
|
|
8 |
options(warn = 1)# print them as they occur
|
|
|
9 |
|
|
|
10 |
plot(0) # this should remain constant
|
|
|
11 |
str(par(c("usr","xaxp","yaxp")))
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
### Test for centring of chars. All the chars which are plotted should
|
|
|
16 |
### be centred, and there should be no warnings about
|
|
|
17 |
### font metrics unknown for character `?'
|
|
|
18 |
|
|
|
19 |
par(pty="s")
|
|
|
20 |
plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="", xaxs="i", yaxs="i")
|
|
|
21 |
title("Centred chars in default char set (ISO Latin1)")
|
|
|
22 |
grid(17, 17, lty=1)
|
| 23077 |
ripley |
23 |
known <- c(32:126, 144:152, 154, 155, 157:255)
|
| 23048 |
ripley |
24 |
|
|
|
25 |
for(i in known) {
|
|
|
26 |
x <- i %% 16
|
|
|
27 |
y <- i %/% 16
|
|
|
28 |
points(x, y, pch=i)
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
par(pty="m")
|
|
|
32 |
|
|
|
33 |
## PR 816 (label sizes in dotchart)
|
|
|
34 |
|
|
|
35 |
### Prior to 1.2.2, the label sizes were unaffected by cex.
|
|
|
36 |
|
|
|
37 |
data(VADeaths)
|
|
|
38 |
dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 0.5)
|
|
|
39 |
dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 1.5)
|
|
|
40 |
|
|
|
41 |
## killed by 0 prior to 1.4.0 and in 1.4.1:
|
|
|
42 |
t1 <- ts(0:100)
|
|
|
43 |
## only warnings about values <= 0
|
|
|
44 |
plot(t1, log = "y")
|
|
|
45 |
plot(cbind(t1, 10*t1, t1 - 4), log="y", plot.type = "single")
|
|
|
46 |
stopifnot(par("usr")[4] > 3) # log10: ylim[2] = 1000
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
## This one needs to be looked at.
|
|
|
50 |
## lty = "blank" killed the fill colour too.
|
|
|
51 |
plot(1:10, type="n")
|
|
|
52 |
polygon(c(1, 3, 3, 1), c(1, 1, 3, 3), col="yellow", border="red", lty="blank")
|
|
|
53 |
rect(6, 6, 10, 10, col="blue", border="red", lty="blank")
|
|
|
54 |
## in 1.5.0 all omit the fill colours.
|
|
|
55 |
data(trees)
|
|
|
56 |
with(trees, symbols(Height, Volume, circles=Girth/24, inches=FALSE,
|
|
|
57 |
lty="blank", bg="blue"))
|
|
|
58 |
## in 1.5.0 ignored the lty.
|
|
|
59 |
|
|
|
60 |
## axis() and par(mgp < 0) {keep this example S+ compatible!}:
|
|
|
61 |
lt <- if(is.R()) "31" else 2
|
|
|
62 |
x <- seq(-2,3, len=1001)
|
|
|
63 |
op <- par(tck= +0.02, mgp = -c(3,2,0))
|
|
|
64 |
plot(x, x^2 - 1.2, xaxt = "n", xlab="", type ='l', col = 2,
|
|
|
65 |
main = "mgp < 0: all ticks and labels inside `frame'")
|
|
|
66 |
x <- -2:3
|
|
|
67 |
lines(x, x^2 - 1.2, type ="h", col = 3, lwd=3)
|
|
|
68 |
axis(1, pos = 0, at=-1:1, lty = lt, col=4)## col & lty work only from R 1.6
|
|
|
69 |
par(op)
|
|
|
70 |
axis(1, pos = 0, at=c(-2,2,3), lty = lt, col=4)
|
|
|
71 |
mtext(side=1,"note the x-ticks on the other side of the bars")
|
|
|
72 |
|
| 23846 |
maechler |
73 |
## plot.table(): explicit xlab and ylab for non-1D
|
| 23048 |
ripley |
74 |
data(UCBAdmissions)
|
|
|
75 |
plot(UCBAdmissions)# default x- and y-lab
|
|
|
76 |
plot(UCBAdmissions, xlab = "x label", ylab = "YY")# wrong in 1.5.1
|
| 23846 |
maechler |
77 |
## axis suppression
|
|
|
78 |
plot(tt <- table(c(rep(0,7), rep(1,4), rep(5, 3))), axes = FALSE)
|
|
|
79 |
plot(tt, xaxt = "n")
|
|
|
80 |
## wrong till (incl.) 1.6.x
|
| 25869 |
maechler |
81 |
|
|
|
82 |
## legend with call
|
|
|
83 |
lo <- legend(2,2, substitute(hat(theta) == that, list(that= pi)))
|
|
|
84 |
stopifnot(length(lo$text$x) == 1)
|
|
|
85 |
## length() was 3 till 1.7.x
|
| 26717 |
maechler |
86 |
|
|
|
87 |
plot(ecdf(c(1:4,8,12)), ylab = "ECDF", main=NULL)
|
|
|
88 |
## ylab didn't work till 1.8.0
|