以下是使用基本图形的开始.让它更漂亮留给读者.您可以在此处查看示例:http://www.math.csi.cuny.edu/gw/ex-dashboard.R.
dashboard <- function(dial=list(
list(color="red",
range=c(10, 40)),
list(color="yellow",
range=c(40, 60)),
list(color="green",
range=c(70, 100))
),
value=from) {
from <- min(unlist(lapply(dial, "[[", i="range")))
to <- max(unlist(lapply(dial, "[[", i="range")))
theta <- seq(-pi/3, pi + pi/3, length=100)
r <- 1
scale <- function(x) {
m <- (pi + pi/3 - (-pi/3))/(from - to)
(pi + pi/3) + m*(x - from)
}
plot.new()
plot.window(xlim=c(-1, 1), ylim=c(sin(-pi/3), 1))
lines(cos(theta), sin(theta))
sapply(dial, function(l) {
d <- scale(l$range)
x <- seq(d[1], d[2], length=100)
lines(cos(x), sin(x), col=l$color, lwd=3)
})
ticks <- pretty(c(from, to), n=5)
ticks_th <- scale(ticks)
r <- 1 - .15
text(r*cos(ticks_th), r*sin(ticks_th), labels=ticks)
sapply(ticks_th, function(th) {
lines(cos(th)*c(1,.95), sin(th)*c(1, .95))
})
r <- 1 - .25
th <- scale(value)
arrows(0, 0, cos(th), sin(th))
}
dashboard( value=60)
Run Code Online (Sandbox Code Playgroud)
你可以用极坐标图做类似的事情:
require(plotrix)
polar.plot( c(0,20),c(0,60),main="Dashboard",lwd=3,line.col=4)
Run Code Online (Sandbox Code Playgroud)
如果要自定义外观,可以深入挖掘代码.使用radial.plot
可能会给你更多的自定义.