Документ взят из кэша поисковой машины. Адрес оригинального документа : http://herba.msu.ru/shipunov/school/biol_240/20160210.r
Дата изменения: Wed Feb 10 22:53:47 2016
Дата индексирования: Sun Apr 10 07:28:53 2016
Кодировка:
example(points)
pchShow <-
function(extras = c("*",".", "o","O","0","+","-","|","%","#"),
cex = 3, ## good for both .Device=="postscript" and "x11"
col = "red3", bg = "gold", coltext = "brown", cextext = 1.2,
main = paste("plot symbols : points (... pch = *, cex =",
cex,")"))
{
nex <- length(extras)
np <- 26 + nex
ipch <- 0:(np-1)
k <- floor(sqrt(np))
dd <- c(-1,1)/2
rx <- dd + range(ix <- ipch %/% k)
ry <- dd + range(iy <- 3 + (k-1)- ipch %% k)
pch <- as.list(ipch) # list with integers & strings
if(nex > 0) pch[26+ 1:nex] <- as.list(extras)
plot(rx, ry, type = "n", axes = FALSE, xlab = "", ylab = "", main = main)
abline(v = ix, h = iy, col = "lightgray", lty = "dotted")
for(i in 1:np) {
pc <- pch[[i]]
## 'col' symbols with a 'bg'-colored interior (where available) :
points(ix[i], iy[i], pch = pc, col = col, bg = bg, cex = cex)
if(cextext > 0)
text(ix[i] - 0.3, iy[i], pc, col = coltext, cex = cextext)
}
}
plot(1:40, pch="*")
plot(1:40, pch=".")
plot(1:40, pch="$")

# colors()
plot(1:40, pch="$", col=5)
plot(1:40, pch="$", col=15)
plot(1:40, pch="$", col=25)
plot(1:40, pch="$", col="red")
plot(1:40, pch="$", col="magenta")
plot(1:40, pch="$", col="tomato")
plot(1:40, pch="$", col=1:40)
plot(1:40, pch="$", col=0:40)

i <- read.table("http://ashipunov.info/data/islets.txt", h=T, sep="\t")
sq <- i[,1] * i[,2] * 0.36
plot(sq, i[,3])
scatter.smooth(sq, i[,3])
plot(log(sq), i[,3])
scatter.smooth(log(sq), i[,3])

la <- read.table("http://ashipunov.info/data/wslakes.txt", h=T, sep="\t")
lsq <- la[,1] * la[,2]
plot(lsq, la[,3])
scatter.smooth(lsq, la[,3])
plot(log(lsq), la[,3])
scatter.smooth(log(lsq), la[,3])

pdf("1.pdf")
scatter.smooth(log(lsq), la[,3])
dev.off()

scatter.smooth(log(lsq), la[,3])
# dev.copy(pdf, "2.pdf") # does not run in non-interactive mode!
# dev.off()

oldpar <- par(mfrow=c(2,1))
scatter.smooth(log(sq), i[,3], main="Islands")
scatter.smooth(log(lsq), la[,3], main="Lakes")
par(oldpar)

pdf("3.pdf")
oldpar <- par(mfrow=c(2,1))
scatter.smooth(log(sq), i[,3], main="Islands")
scatter.smooth(log(lsq), la[,3], main="Lakes")
par(oldpar) # actually, not necessary here, added for safety
dev.off()

plot(1:20)
text(5,6,"something")
# text(locator(), "something else") # interactive!

plot(USArrests[,1], USArrests[,3])
# identify(USArrests[,1], USArrests[,3], row.names(USArrests)) # interactive!