窃以为让读者读颜色不如读大小更直接(遇到色盲就更麻烦了),如
quake6 = read.csv("http://dl.dropbox.com/u/3824701/earthquacks.csv")<br />
## 若以上地址不可用,可以换作下面的地址试试<br />
## http://download664.mediafire.com/fwzyiwmwkQjg/zztijczjgga/earthquacks.csv<br />
library(ggplot2)<br />
qplot(year, month, data = quake6) + stat_sum(aes(size = ..n..)) +<br />
scale_size(to = c(1, 10))
</p>
[attachment=203404,164]
要玩地图也不是难事,根据数据中的经度纬度画点就好了,如(给个按年份来的动画):
library(maps)<br />
## 去掉下面的注释,可以用animation包生成HTML页面动画<br />
# library(animation)<br />
# ani.start(ani.width = 500, ani.height = 300)<br />
par(mar = rep(0, 4), pch = 19, col = rgb(0, 0, 0, 0.7))<br />
for (i in unique(quake6$year)) {<br />
map(col = "gray")<br />
text(-10, -50, i, cex = 2, col = "gray")<br />
with(quake6, points(long[year == i], lat[year == i]))<br />
# Sys.sleep(1)<br />
}<br />
# ani.stop()
</p>
[attachment=203404,165]
如果感兴趣的话,这里是生成帖子中GIF动画的代码:
saveMovie({<br />
par(mar = rep(0, 4), pch = 19, col = rgb(0, 0, 0, 0.7))<br />
for (i in unique(quake6$year)) {<br />
map(col = "gray")<br />
text(-10, -50, i, cex = 2, col = "gray")<br />
with(quake6, points(long[year == i], lat[year == i]))<br />
}<br />
}, width = 500, height = 300, moviename = "quake-map-by-year")<br />
</p>