The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

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