The R Project SVN R

Rev

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

Rev 68769 Rev 68809
1
 
1
 
2
R Under development (unstable) (2015-07-31 r68768) -- "Unsuffered Consequences"
2
R Under development (unstable) (2015-08-03 r68808) -- "Unsuffered Consequences"
3
Copyright (C) 2015 The R Foundation for Statistical Computing
3
Copyright (C) 2015 The R Foundation for Statistical Computing
4
Platform: x86_64-unknown-linux-gnu (64-bit)
4
Platform: x86_64-pc-linux-gnu (64-bit)
5
 
5
 
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
7
You are welcome to redistribute it under certain conditions.
8
Type 'license()' or 'licence()' for distribution details.
8
Type 'license()' or 'licence()' for distribution details.
9
 
9
 
10
R is a collaborative project with many contributors.
10
R is a collaborative project with many contributors.
11
Type 'contributors()' for more information and
11
Type 'contributors()' for more information and
12
'citation()' on how to cite R or R packages in publications.
12
'citation()' on how to cite R or R packages in publications.
13
 
13
 
14
Type 'demo()' for some demos, 'help()' for on-line help, or
14
Type 'demo()' for some demos, 'help()' for on-line help, or
15
'help.start()' for an HTML browser interface to help.
15
'help.start()' for an HTML browser interface to help.
16
Type 'q()' to quit R.
16
Type 'q()' to quit R.
17
 
17
 
18
> #### Regression tests for GRAPHICS & PLOTS
18
> #### Regression tests for GRAPHICS & PLOTS
19
> 
19
> 
20
> pdf("reg-plot.pdf", paper="a4r", encoding ="ISOLatin1.enc", compress = FALSE)
20
> pdf("reg-plot.pdf", paper="a4r", encoding ="ISOLatin1.enc", compress = FALSE)
21
> 
21
> 
22
> ## since we supply the font metrics, the results depend only on
22
> ## since we supply the font metrics, the results depend only on
23
> ## the encoding used: Windows is different from Unix by default.
23
> ## the encoding used: Windows is different from Unix by default.
24
> 
24
> 
25
> options(warn = 1) # print as they occur
25
> options(warn = 1) # print as they occur
26
> 
26
> 
27
> plot(0) # this should remain constant
27
> plot(0) # this should remain constant
28
> str(par(c("usr","xaxp","yaxp")))
28
> str(par(c("usr","xaxp","yaxp")))
29
List of 3
29
List of 3
30
 $ usr : num [1:4] 0.568 1.432 -1.08 1.08
30
 $ usr : num [1:4] 0.568 1.432 -1.08 1.08
31
 $ xaxp: num [1:3] 0.6 1.4 4
31
 $ xaxp: num [1:3] 0.6 1.4 4
32
 $ yaxp: num [1:3] -1 1 4
32
 $ yaxp: num [1:3] -1 1 4
33
> 
33
> 
34
> 
34
> 
35
> 
35
> 
36
> ### Test for centring of chars.  All the chars which are plotted should
36
> ### Test for centring of chars.  All the chars which are plotted should
37
> ### be centred, and there should be no warnings about
37
> ### be centred, and there should be no warnings about
38
> ### font metrics unknown for character `?'
38
> ### font metrics unknown for character `?'
39
> 
39
> 
40
> par(pty="s")
40
> par(pty="s")
41
> plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="", xaxs="i", yaxs="i")
41
> plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="", xaxs="i", yaxs="i")
42
> title("Centred chars in default char set (ISO Latin1)")
42
> title("Centred chars in default char set (ISO Latin1)")
43
> grid(17, 17, lty=1)
43
> grid(17, 17, lty=1)
44
> known <- c(32:126, 160:255)
44
> known <- c(32:126, 160:255)
45
> 
45
> 
46
> for(i in known) {
46
> for(i in known) {
47
+     x <- i %% 16
47
+     x <- i %% 16
48
+     y <- i %/% 16
48
+     y <- i %/% 16
49
+     points(x, y, pch=-i)
49
+     points(x, y, pch=-i)
50
+ }
50
+ }
51
> 
51
> 
52
> par(pty="m")
52
> par(pty="m")
53
> 
53
> 
54
> ## PR 816 (label sizes in dotchart)
54
> ## PR 816 (label sizes in dotchart)
55
> 
55
> 
56
> ### Prior to 1.2.2, the label sizes were unaffected by cex.
56
> ### Prior to 1.2.2, the label sizes were unaffected by cex.
57
> 
57
> 
58
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 0.5)
58
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 0.5)
59
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 1.5)
59
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940", cex = 1.5)
60
> 
60
> 
61
> ## killed by 0 prior to 1.4.0 and in 1.4.1:
61
> ## killed by 0 prior to 1.4.0 and in 1.4.1:
62
> t1 <- ts(0:100)
62
> t1 <- ts(0:100)
63
> ## only warnings about values <= 0
63
> ## only warnings about values <= 0
64
> plot(t1, log = "y")
64
> plot(t1, log = "y")
65
Warning in xy.coords(x, NULL, log = log) :
65
Warning in xy.coords(x, NULL, log = log) :
66
  1 y value <= 0 omitted from logarithmic plot
66
  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, ...) : 
115
Error in plot.xy(xy.coords(x, y), type = type, ...) : 
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
> 
127
> plot(as.Date("2001/1/1") + 12*(1:9), 1:9)
127
> plot(as.Date("2001/1/1") + 12*(1:9), 1:9)
128
> ## used bad 'xlab/ylab' in some versions of R 2.2.0(unstable)
128
> ## used bad 'xlab/ylab' in some versions of R 2.2.0(unstable)
129
> 
129
> 
130
> ## dotchart() restoring par()
130
> ## dotchart() restoring par()
131
> Opar <- par(no.readonly=TRUE) ; dotchart(1:4, cex= 0.7)
131
> Opar <- par(no.readonly=TRUE) ; dotchart(1:4, cex= 0.7)
132
> Npar <- par(no.readonly=TRUE)
132
> Npar <- par(no.readonly=TRUE)
133
> ii <- c(37, 50:51, 58:59, 63)
133
> ii <- c(37, 50:51, 58:59, 63)
134
> stopifnot(identical(names(Opar)[ii],
134
> stopifnot(identical(names(Opar)[ii],
135
+                     c("mai","pin","plt","usr","xaxp","yaxp")),
135
+                     c("mai","pin","plt","usr","xaxp","yaxp")),
136
+           identical(Opar[-ii], Npar[-ii]))
136
+           identical(Opar[-ii], Npar[-ii]))
137
> ## did not correctly restore par("mar") up to (incl) R 2.4.0
137
> ## did not correctly restore par("mar") up to (incl) R 2.4.0
138
> 
138
> 
139
> ## plot.function()     [n=11, ... : since we store and diff PS file !]
139
> ## plot.function()     [n=11, ... : since we store and diff PS file !]
140
> plot(cos,       xlim=c(-5,5), n=11, axes=FALSE); abline(v=0)
140
> plot(cos,       xlim=c(-5,5), n=11, axes=FALSE); abline(v=0)
141
> ## did *not* plot for negative x up to R 2.5.1
141
> ## did *not* plot for negative x up to R 2.5.1
142
> plot(sin, -2,3, xlim=c(-5,5), n=11, axes=FALSE, xlab="")# plot from -2
142
> plot(sin, -2,3, xlim=c(-5,5), n=11, axes=FALSE, xlab="")# plot from -2
143
> axis(1, at=c(-2,3), tcl=-1); axis(1, at=c(-5,5))
143
> axis(1, at=c(-2,3), tcl=-1); axis(1, at=c(-5,5))
144
> ## (from,to) & xlim  should work simultaneously
144
> ## (from,to) & xlim  should work simultaneously
145
> 
145
> 
146
> plot(cos, -7,7, n=11, axes=FALSE)
146
> plot(cos, -7,7, n=11, axes=FALSE)
147
> ## gave wrong ylab in R 2.6.0
147
> ## gave wrong ylab in R 2.6.0
148
> plot(cos, -7,7, ylab = "Cosine  cos(x)", n=11, axes=FALSE)
148
> plot(cos, -7,7, ylab = "Cosine  cos(x)", n=11, axes=FALSE)
149
> ## partial matching of 'ylab'; mapping  [0,1] (not [-7.7]):
149
> ## partial matching of 'ylab'; mapping  [0,1] (not [-7.7]):
150
> ## margins chosen to avoid rouding error showing to 2dp.
150
> ## margins chosen to avoid rouding error showing to 2dp.
151
> op <- par(mar=c(5,4.123,4,2)+0.1)
151
> op <- par(mar=c(5,4.123,4,2)+0.1)
152
> plot(gamma, yla = expression(Gamma(x)), n=11, yaxt="n")
152
> plot(gamma, yla = expression(Gamma(x)), n=11, yaxt="n")
153
Warning in x(x) : NaNs produced
153
Warning in x(x) : NaNs produced
154
> par(op)
154
> par(op)
155
> 
155
> 
156
> ## plot.ts(x, y) could get the labels wrong in R <= 2.6.0:
156
> ## plot.ts(x, y) could get the labels wrong in R <= 2.6.0:
157
> x <- ts(1:5);x1 <- lag(x, 2); plot(x1, x, axes=FALSE)
157
> x <- ts(1:5);x1 <- lag(x, 2); plot(x1, x, axes=FALSE)
158
> 
158
> 
159
> # adding a curve in log scale :
159
> # adding a curve in log scale :
160
> curve(5*exp(-x), 0.1, 100, n = 3, log="x", ylab="", axes=FALSE)
160
> curve(5*exp(-x), 0.1, 100, n = 3, log="x", ylab="", axes=FALSE)
161
> curve(5*exp(-x), add=TRUE, n = 3, col=2,lwd=3)
161
> curve(5*exp(-x), add=TRUE, n = 3, col=2,lwd=3)
162
> ## should fully overplot; wrong default xlim in 2.6.1
162
> ## should fully overplot; wrong default xlim in 2.6.1
163
> ## (and *slightly* wrong up to 2.6.0)
163
> ## (and *slightly* wrong up to 2.6.0)
164
> 
164
> 
165
> ## Axis() calls via plot()  {[xy]axt to keep *.ps small}
165
> ## Axis() calls via plot()  {[xy]axt to keep *.ps small}
166
> x <- as.Date("2008-04-22 09:45") + (i <- c(0,4))
166
> x <- as.Date("2008-04-22 09:45") + (i <- c(0,4))
167
> plot(x,    xaxt="n")# not ok in 2.6.2, nor 2.7.0
167
> plot(x,    xaxt="n")# not ok in 2.6.2, nor 2.7.0
168
> plot(x, i, yaxt="n")# ok in 2.6.2  and 2.7.0
168
> plot(x, i, yaxt="n")# ok in 2.6.2  and 2.7.0
169
> plot(i, x, xaxt="n")# ok in 2.6.2 and not in 2.7.0
169
> plot(i, x, xaxt="n")# ok in 2.6.2 and not in 2.7.0
170
> 
170
> 
171
> ## table methods should be bypassed:
171
> ## table methods should be bypassed:
172
> dotchart(table(infert$education))
172
> dotchart(table(infert$education))
173
Warning in dotchart(table(infert$education)) :
173
Warning in dotchart(table(infert$education)) :
174
  'x' is neither a vector nor a matrix: using as.numeric(x)
174
  'x' is neither a vector nor a matrix: using as.numeric(x)
175
> ## failed in 2.12.[12]
175
> ## failed in 2.12.[12]
176
> 
176
> 
177
> ## cex as "..."  in "high level" function
177
> ## cex as "..."  in "high level" function
178
> hc <- hclust(dst <- dist(c(1:2, 5)), method="ave")
178
> hc <- hclust(dst <- dist(c(1:2, 5)), method="ave")
179
> plot(hc, cex = 2, axes=FALSE, ann=FALSE)
179
> plot(hc, cex = 2, axes=FALSE, ann=FALSE)
180
> ## cex was not used in 3.0.[01]
180
> ## cex was not used in 3.0.[01]
181
> 
181
> 
182
> 
182
>