# graphics - visualizations - r scatter plot

## 大多數未充分利用的數據可視化 (10)

1. 在實踐中不常用。
2. 沒有很多背景討論就可以理解。
3. 適用於許多常見情況。
4. 包含可重複的代碼來創建一個示例（最好在R中）。 鏈接的圖像會很好。

``````library(mlbench) ## this package has a smiley function
n <- 1e5 ## number of points
p <- mlbench.smiley(n,sd1 = 0.4, sd2 = 0.4) ## make a smiley :-)
x <- p\$x[,1]; y <- p\$x[,2]
par(mfrow = c(1,2)) ## plot side by side
plot(x,y) ## left plot, regular scatter plot
smoothScatter(x,y) ## right plot, smoothed scatter plot
``````

`hexbin`軟件包（由@Dirk Eddelbuettel提供）用於相同的目的，但`smoothScatter()`具有屬於`graphics`軟件包的優點，因此它是標準R安裝的一部分。

``````library(lattice)
library(taRifx)
compareplot(~weight | Diet * Time * Chick,
data.frame=cw ,
main = "Chick Weights",
box.show.mean=FALSE,
box.show.whiskers=FALSE,
box.show.box=FALSE
)
``````

``````stock <- "MSFT"
start.date <- "2006-01-12"
end.date <- Sys.Date()
quote <- paste("http://ichart.finance.yahoo.com/table.csv?s=",
stock, "&a=", substr(start.date,6,7),
"&b=", substr(start.date, 9, 10),
"&c=", substr(start.date, 1,4),
"&d=", substr(end.date,6,7),
"&e=", substr(end.date, 9, 10),
"&f=", substr(end.date, 1,4),
"&g=d&ignore=.csv", sep="")
stock.data <- transform(stock.data,
week = as.POSIXlt(Date)\$yday %/% 7 + 1,
wday = as.POSIXlt(Date)\$wday,
year = as.POSIXlt(Date)\$year + 1900)

library(ggplot2)
ggplot(stock.data, aes(week, wday, fill = Adj.Close)) +
geom_tile(colour = "white") +
facet_wrap(~ year, ncol = 1)
``````

RGL：交互式3D圖形

R-Wiki有一個很好的例子 ，說明如何使用rgl繪製三維散點圖。

GGobi

``````boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
``````