Some days ago, I saw a China map in LinQuan’s blog, which showing Lin has been.
The map could also be printed by R.
The following map (76038×2) is printed using R – The provinces I have visited
and the per capita disposable income in China.
代码如下:
plot(1,xlim=c(0,2*pi),ylim=c(-2,2),type='n',axes = F,ann=F) x=seq(0,2*pi,.01) lines(x,0.6*sin(x),lwd=2) lines(x,0.6*sin(x-pi),lty=2,col='red') segments(0,0,.5,1.5,lwd=2) segments(2*pi,0,2*pi-.5,1.5,lwd=2) points(pi/2,0,pch = 21, cex = 12) points(3*pi/2,0,pch = 21, cex = 12 ,bg = "black") segments(pi,0,pi,-1, lwd = 2) points(pi-0.2,-1,pch = 21, cex = 4) points(pi+0.2,-1,pch = 21, cex = 4) m <- seq(pi-1,pi+1,length = 100) f1 <- function(x) -1-dnorm(x,mean = pi) y1 <- f1(m) f2 <- function(x)0.5*(x-pi)^2 tmp <- f2(m) y2 <- f2(m) - (tmp[1]-y1[1]) polygon(c(m,m),c(y1,y2),col = "maroon1" ,border = NA)
纯属娱乐,看到绘图以后不要胡思乱想 ……
function (x, y, h, n = 25, lims = c(range(x), range(y))) { nx <- length(x) if (length(y) != nx) stop("data vectors must be the same length") gx <- seq(lims[1], lims[2], length = n) gy <- seq(lims[3], lims[4], length = n) if (missing(h)) h <- c(bandwidth.nrd(x), bandwidth.nrd(y)) h <- h/4 ax <- outer(gx, x, "-")/h[1] ay <- outer(gy, y, "-")/h[2] z <- matrix(dnorm(ax), n, nx) %*% t(matrix(dnorm(ay), n, nx))/(nx * h[1] * h[2]) return(list(x = gx, y = gy, z = z)) } bandwidth.nrd(x) <- function (x) { r <- quantile(x, c(0.25, 0.75)) h <- (r[2] – r[1])/1.34 4 * 1.06 * min(sqrt(var(x)), h) * length(x)^(-1/5) }
Pie charts are a very bad way of displaying information.
from R-help
The pie chart is invented by Playfair in 1786. Among statisticians, however, the pie chart is generally deprecated in favor of the bar chart, usually on the blief that judgments of relative areas or angles are more difficult than judgment of length. In Tufte’s (1983) view, for example, “the only design worse than a pie chart is several of them … pie charts should never be used”. The prevailing views and the results of influential studies by Cleveland & McGill (1984, 1986) continue to lead statisticians to hold the pie chart in disfavor.
| © 2010 刘思喆 @ 贝吉塔行星 | Suffusion WordPress theme by Sayontan Sinha |