The R Project SVN R

Rev

Rev 33361 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33361 Rev 33425
1
 
1
 
2
R : Copyright 2005, The R Foundation for Statistical Computing
2
R : Copyright 2005, The R Foundation for Statistical Computing
3
Version 2.1.0 Under development (unstable) (2005-02-26), ISBN 3-900051-07-0
3
Version 2.1.0 Under development (unstable) (2005-02-26), ISBN 3-900051-07-0
4
 
4
 
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
You are welcome to redistribute it under certain conditions.
6
You are welcome to redistribute it under certain conditions.
7
Type 'license()' or 'licence()' for distribution details.
7
Type 'license()' or 'licence()' for distribution details.
8
 
8
 
9
R is a collaborative project with many contributors.
9
R is a collaborative project with many contributors.
10
Type 'contributors()' for more information and
10
Type 'contributors()' for more information and
11
'citation()' on how to cite R or R packages in publications.
11
'citation()' on how to cite R or R packages in publications.
12
 
12
 
13
Type 'demo()' for some demos, 'help()' for on-line help, or
13
Type 'demo()' for some demos, 'help()' for on-line help, or
14
'help.start()' for a HTML browser interface to help.
14
'help.start()' for a HTML browser interface to help.
15
Type 'q()' to quit R.
15
Type 'q()' to quit R.
16
 
16
 
17
> #### Regression tests for GRAPHICS & PLOTS
17
> #### Regression tests for GRAPHICS & PLOTS
18
> 
18
> 
19
> postscript("reg-plot.ps", paper="a4", horizontal=TRUE,
19
> postscript("reg-plot.ps", paper="a4", horizontal=TRUE,
20
+            encoding ="ISOLatin1.enc")
20
+            encoding ="ISOLatin1.enc")
21
> ## since we supply the font metrics, the results depend only on
21
> ## since we supply the font metrics, the results depend only on
22
> ## the encoding used: Windows is different from Unix by default.
22
> ## the encoding used: Windows is different from Unix by default.
23
> ## As from 2.1.0 we only test genuine Latin-1 chars: Adobe has dotlessi
23
> ## As from 2.1.0 we only test genuine Latin-1 chars: Adobe has dotlessi
24
> ## and accents at 144:152, 154, 155, 157:159, but Unicode does not.
24
> ## and accents at 144:152, 154, 155, 157:159, but Unicode does not.
25
> 
25
> 
26
> options(warn = 1)# print them as they occur
26
> options(warn = 1)# print them as they occur
27
> 
27
> 
28
> plot(0) # this should remain constant
28
> plot(0) # this should remain constant
29
> str(par(c("usr","xaxp","yaxp")))
29
> str(par(c("usr","xaxp","yaxp")))
30
List of 3
30
List of 3
31
 $ usr : num [1:4]  0.568  1.432 -1.080  1.080
31
 $ usr : num [1:4]  0.568  1.432 -1.080  1.080
32
 $ xaxp: num [1:3] 0.6 1.4 4.0
32
 $ xaxp: num [1:3] 0.6 1.4 4.0
33
 $ yaxp: num [1:3] -1 1 4
33
 $ yaxp: num [1:3] -1 1 4
34
> 
34
> 
35
> 
35
> 
36
> 
36
> 
37
> ### Test for centring of chars.  All the chars which are plotted should
37
> ### Test for centring of chars.  All the chars which are plotted should
38
> ### be centred, and there should be no warnings about
38
> ### be centred, and there should be no warnings about
39
> ### font metrics unknown for character `?'
39
> ### font metrics unknown for character `?'
40
> 
40
> 
41
> par(pty="s")
41
> par(pty="s")
42
> plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="", xaxs="i", yaxs="i")
42
> plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="", xaxs="i", yaxs="i")
43
> title("Centred chars in default char set (ISO Latin1)")
43
> title("Centred chars in default char set (ISO Latin1)")
44
> grid(17, 17, lty=1)
44
> grid(17, 17, lty=1)
45
> known <- c(32:126, 160:255)
45
> known <- c(32:126, 160:255)
46
> 
46
> 
47
> for(i in known) {
47
> for(i in known) {
48
+     x <- i %% 16
48
+     x <- i %% 16
49
+     y <- i %/% 16
49
+     y <- i %/% 16
50
+     points(x, y, pch=i)
50
+     points(x, y, pch=i)
51
+ }
51
+ }
52
> 
52
> 
53
> par(pty="m")
53
> par(pty="m")
54
> 
54
> 
55
> ## PR 816 (label sizes in dotchart)
55
> ## PR 816 (label sizes in dotchart)
56
> 
56
> 
57
> ### Prior to 1.2.2, the label sizes were unaffected by cex.
57
> ### Prior to 1.2.2, the label sizes were unaffected by cex.
58
> 
58
> 
59
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 0.5)
59
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 0.5)
60
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 1.5)
60
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 1.5)
61
> 
61
> 
62
> ## killed by 0 prior to 1.4.0 and in 1.4.1:
62
> ## killed by 0 prior to 1.4.0 and in 1.4.1:
63
> t1 <- ts(0:100)
63
> t1 <- ts(0:100)
64
> ## only warnings about values <= 0
64
> ## only warnings about values <= 0
65
> plot(t1, log = "y")
65
> plot(t1, log = "y")
66
Warning in xy.coords(x, NULL, log = log) : one y value <= 0 omitted from logarithmic plot
66
Warning in xy.coords(x, NULL, log = log) : 1 y value <= 0 omitted from logarithmic plot
67
> plot(cbind(t1, 10*t1, t1 - 4), log="y", plot.type = "single")
67
> plot(cbind(t1, 10*t1, t1 - 4), log="y", plot.type = "single")
68
Warning in xy.coords(x = matrix(rep.int(tx, k), ncol = k), y = x, log = log) : 
68
Warning in xy.coords(x = matrix(rep.int(tx, k), ncol = k), y = x, log = log) : 
69
	 7 y values <= 0 omitted from logarithmic plot
69
	 7 y values <= 0 omitted from logarithmic plot
70
> stopifnot(par("usr")[4] > 3) # log10: ylim[2] = 1000
70
> stopifnot(par("usr")[4] > 3) # log10: ylim[2] = 1000
71
> 
71
> 
72
> 
72
> 
73
> ## This one needs to be looked at.
73
> ## This one needs to be looked at.
74
> ## lty = "blank" killed the fill colour too.
74
> ## lty = "blank" killed the fill colour too.
75
> plot(1:10, type="n")
75
> plot(1:10, type="n")
76
> polygon(c(1, 3, 3, 1), c(1, 1, 3, 3), col="yellow", border="red", lty="blank")
76
> polygon(c(1, 3, 3, 1), c(1, 1, 3, 3), col="yellow", border="red", lty="blank")
77
> rect(6, 6, 10, 10,  col="blue", border="red", lty="blank")
77
> rect(6, 6, 10, 10,  col="blue", border="red", lty="blank")
78
> ## in 1.5.0 all omit the fill colours.
78
> ## in 1.5.0 all omit the fill colours.
79
> with(trees, symbols(Height, Volume, circles=Girth/24, inches=FALSE,
79
> with(trees, symbols(Height, Volume, circles=Girth/24, inches=FALSE,
80
+                     lty="blank", bg="blue"))
80
+                     lty="blank", bg="blue"))
81
> ## in 1.5.0 ignored the lty.
81
> ## in 1.5.0 ignored the lty.
82
> 
82
> 
83
> ## axis() and par(mgp < 0) {keep this example S+ compatible!}:
83
> ## axis() and par(mgp < 0) {keep this example S+ compatible!}:
84
> lt <- if(is.R()) "31" else 2
84
> lt <- if(is.R()) "31" else 2
85
> x <- seq(-2,3, len=1001)
85
> x <- seq(-2,3, len=1001)
86
> op <- par(tck= +0.02, mgp = -c(3,2,0))
86
> op <- par(tck= +0.02, mgp = -c(3,2,0))
87
> plot(x, x^2 - 1.2, xaxt = "n", xlab="", type ='l', col = 2,
87
> plot(x, x^2 - 1.2, xaxt = "n", xlab="", type ='l', col = 2,
88
+      main = "mgp < 0: all ticks and labels inside `frame'")
88
+      main = "mgp < 0: all ticks and labels inside `frame'")
89
> x <- -2:3
89
> x <- -2:3
90
> lines(x, x^2 - 1.2, type ="h", col = 3, lwd=3)
90
> lines(x, x^2 - 1.2, type ="h", col = 3, lwd=3)
91
> axis(1, pos = 0, at=-1:1, lty = lt, col=4)## col & lty work only from R 1.6
91
> axis(1, pos = 0, at=-1:1, lty = lt, col=4)## col & lty work only from R 1.6
92
> par(op)
92
> par(op)
93
> axis(1, pos = 0, at=c(-2,2,3), lty = lt, col=4)
93
> axis(1, pos = 0, at=c(-2,2,3), lty = lt, col=4)
94
> mtext(side=1,"note the x-ticks on the other side of the bars")
94
> mtext(side=1,"note the x-ticks on the other side of the bars")
95
> 
95
> 
96
> ## plot.table(): explicit xlab and ylab for non-1D
96
> ## plot.table(): explicit xlab and ylab for non-1D
97
> plot(UCBAdmissions)# default x- and y-lab
97
> plot(UCBAdmissions)# default x- and y-lab
98
> plot(UCBAdmissions, xlab = "x label", ylab = "YY")# wrong in 1.5.1
98
> plot(UCBAdmissions, xlab = "x label", ylab = "YY")# wrong in 1.5.1
99
> ##   axis suppression
99
> ##   axis suppression
100
> plot(tt <- table(c(rep(0,7), rep(1,4), rep(5, 3))), axes = FALSE)
100
> plot(tt <- table(c(rep(0,7), rep(1,4), rep(5, 3))), axes = FALSE)
101
> plot(tt, xaxt = "n")
101
> plot(tt, xaxt = "n")
102
> ## wrong till (incl.) 1.6.x
102
> ## wrong till (incl.) 1.6.x
103
> 
103
> 
104
> ## legend with call
104
> ## legend with call
105
> lo <- legend(2,2, substitute(hat(theta) == that, list(that= pi)))
105
> lo <- legend(2,2, substitute(hat(theta) == that, list(that= pi)))
106
> stopifnot(length(lo$text$x) == 1)
106
> stopifnot(length(lo$text$x) == 1)
107
> ## length() was 3 till 1.7.x
107
> ## length() was 3 till 1.7.x
108
> 
108
> 
109
> plot(ecdf(c(1:4,8,12)), ylab = "ECDF", main=NULL)
109
> plot(ecdf(c(1:4,8,12)), ylab = "ECDF", main=NULL)
110
> ## ylab didn't work till 1.8.0
110
> ## ylab didn't work till 1.8.0
111
> 
111
> 
112
> plot(1:10, pch = NA) # gave error till 1.9.0
112
> plot(1:10, pch = NA) # gave error till 1.9.0
113
> points(1:3, pch=c("o",NA,"x"))# used "N"
113
> points(1:3, pch=c("o",NA,"x"))# used "N"
114
> try(points(4, pch=c(NA,FALSE)))# still give an error
114
> try(points(4, pch=c(NA,FALSE)))# still give an error
115
Error in plot.xy(xy.coords(x, y), type = type, pch = pch, col = col, bg = bg,  : 
115
Error in plot.xy(xy.coords(x, y), type = type, pch = pch, col = col, bg = bg,  : 
116
	only NA allowed in logical plotting symbol
116
	only NA allowed in logical plotting symbol
117
> 
117
> 
118
> ## 'lwd' should transfer to plot symbols
118
> ## 'lwd' should transfer to plot symbols
119
> legend(1,10, c("A","bcd"), lwd = 2:3, pch= 21:22, pt.bg="skyblue",
119
> legend(1,10, c("A","bcd"), lwd = 2:3, pch= 21:22, pt.bg="skyblue",
120
+        col = 2:3, bg = "thistle")
120
+        col = 2:3, bg = "thistle")
121
> ## (gave an error for 2 days in "2.0.0 unstable")
121
> ## (gave an error for 2 days in "2.0.0 unstable")
122
> 
122
> 
123
> x <- 2^seq(1,1001, length=20)
123
> x <- 2^seq(1,1001, length=20)
124
> plot(x, x^0.9, type="l", log="xy")
124
> plot(x, x^0.9, type="l", log="xy")
125
> ## gave error 'Infinite axis extents [GEPretty(1.87013e-12,inf,5)]' for R 2.0.1
125
> ## gave error 'Infinite axis extents [GEPretty(1.87013e-12,inf,5)]' for R 2.0.1
126
> 
126
>