您的位置:首页 > 其它

使用R进行数据可视化套路之-散点图、图形分隔、时间序列

2013-10-27 16:08 309 查看
代码

## Panel A
par(fig=c(0, 1, .45, 1)) #图像设备分割

plot(log10(measles), xlab="时间", ylab=" Deaths; Population (log scale)", ylim=log10 (c(1,5000*1000)), yaxt="n")
ytiks <- c(1, 10, 100, 1000, 1000000, 5000000)
axis(2, at=log10(ytiks), labels=paste(ytiks), las=2) #坐标轴标记

## London population in thousands
londonpop <- ts(c(1088,1258,1504,1778,2073,2491,2921,3336,388,4563,4541,4498,4408), start=1801, end=1931, deltat=10) #创建时序数据
points(log10(londonpop*1000), pch=16, cex=.5)

mtext(side=3, line=0.5, "A (1629-1939)", adj=0)

## Panel B
par(fig=c(0, 1, 0, .45), new=TRUE)

plot(window(measles, start=1840, end=1882),xlab="时间", ylim=c(0, 4600), yaxt="n") #使用window函数进行时序序列区间数据截取
axis(2, at=(0:4)* 1000, labels=paste(0:4), las=2)

points(londonpop, pch=16, cex=.5)

mtext(side=3, line=0.5, "B (1841-1881)", adj=0)


效果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: