http://www.cs.uoregon.edu/Classes/09W/cis455/lectures/visualization.R.pdf
http://panda0411.com/2012/02/24/r%E8%AF%AD%E8%A8%80%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E7%BB%98%E5%88%B6%E5%9B%BE%E5%BD%A2/
====================
简单二维图:点,曲线,建议参考:
====================
最容易想到的画图函数就是plot了
R中当然也有它。
最常画的图就是二维曲线图了。
现在我们用plot来画它
既然是画二维图,
第一步,当然是将x,y的值序列都建立好
e.g.
这里就随机构造10个数
x <- rnorm(10)
y <- rnorm(10)
然后用plot(x,y)&#xff0c;当然可以得到一个由R来为你制定的最简单的二维图
第二步&#xff0c;
你可以决定&#xff1a;
确定X,Y坐标名称&#xff1a; xlab &#61; "name of x-axis" ylab &#61; "name of y-axis"
X,Y坐标范围:xlim &#61; c(-2,2) ylim &#61; c(-2,2)
决定画点还是画线:
如果是点图&#xff0c;可以决定点的形状 pch &#61; ? (还可以由clo和bg制定轮廓色)
e.g.
plot (x, y, xlab &#61; "Ten random values", ylab &#61; "Ten other random values",
xlim &#61; c(-2,2), ylim &#61; c(-2,2), pch &#61; 22, col &#61; "red", bg &#61; "yellow" )
title("How to customize a plot with R", font.main &#61; 3, adj &#61; 1)
如果是线图&#xff1a;
这里给出一个很好的例子&#xff1a;
&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;
二维曲线图&#43;差异显示
&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;
示意图&#xff1a;
原始数据&#xff1a;
季度 | 目标 | 实际 | 中间值 | 差异 |
第一季度 | 320 | 260 | 290 | -60 |
第二季度 | 300 | 280 | 290 | -20 |
第三季度 | 350 | 390 | 370 | 40 |
第四季度 | 300 | 380 | 340 | 80 |
代码&#xff1a;
x <- c(320, 300, 350, 300 )
z <- c(260, 280, 390, 380)
plot(x, ylim &#61; c(200, 450), type &#61; &#39;n&#39;, axes &#61; FALSE, xlab &#61; &#39;&#39;, ylab &#61; &#39;&#39;)
lines(spline(x, n &#61; 1000), col &#61; &#39;red&#39;, lwd &#61; 2)
lines(spline(z, n &#61; 1000), col &#61; &#39;blue&#39;, lwd &#61; 2)
axis(1,at &#61; 1:4, labels &#61; paste(&#39;第&#39;,1:4,&#39;季度&#39;,sep &#61; &#39;&#39;))
axis(2, las &#61; 1)
box()
for(i in 1:4) arrows(i , x[i], i, z[i], length &#61; 0.15, angle &#61; 20, lwd &#61; 2.5, col &#61; &#39;brown&#39;)
for(i in 1:4) text(i, (x[i] &#43; z[i])/2, (z - x)[i], col &#61; gray(0.7))
legend(&#39;topleft&#39;, c("实际", "目标"), col &#61; c(&#39;blue&#39;,&#39;red&#39;), lty &#61; 1, lwd &#61; 2)
&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;接下来介绍一些专题图的绘制&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;
&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;
热点图 heatmap&#xff1a;http://www.cnblogs.com/wentingtu/archive/2012/03/15/2399458.html
&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;