你可以使用gridBase
軟件包來做類似的事情。我們繼續使用rose.diag
和我們hack
的情節,一旦我們在良好的視口空間。
require(grid)
#grid.newpage()
##generate some data
x <- circular(runif(50, 0, 2*pi))
bins <- 8
rotation <- 'clock'
##tcl =0(no ticks), tcl.text=-2 to write away the ticks marks
rose.diag(x, bins=bins,zero=0, rotation='clock',
tcl=0,tcl.text=-2,col='#80FF00FF')
library(gridBase)
## I use the plot viewport
vp <- baseViewports()$plot
pushViewport(vp) ## here we go!
## radial transformation
at <- (0:bins - 0.5)/bins * 2 * pi
## ticks
grid.segments(x0 = .95*sin(at), y0 = 0.95*cos(at),
x1 = 1.05*sin(at), y1 = 1.05*cos(at),
default.units = "native")
## ticks labels
grid.text(x = 1.1*sin(at), default.units = "native",
y = 1.1*cos(at), gp=gpar(col='red'),
label = c("N", "NE", "E", "SE", "S", "SW", "W", "NW"))
對於視覺方面我想補充一些調整,但一些代碼,上面已經回答的問題。
## dashed lines from the center for visual aspect
grid.segments(x0 = .95*sin(at), y0 = 0.95*cos(at),
x1 = 0, 0,
gp = gpar(lty="dashed"),
default.units = "native")
## circle just to get the same color of text
grid.circle(r=1,x=0,y=0,gp=gpar(col='red',fill=NA,lwd=2), default.units = "native")
## remove the viewport
popViewport(1)
我不認爲這是可能沒有黑客的源代碼。我似乎記得在某些時候這樣做,但將不得不挖掘代碼... –
@BenBolker可能沒有黑客的源代碼,但與黑客的陰謀:) – agstudy