Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
曲线图上数据点的R箭头标记_R_Plot - Fatal编程技术网

曲线图上数据点的R箭头标记

曲线图上数据点的R箭头标记,r,plot,R,Plot,我希望用索引标记数据点——通过目视检查轻松识别索引号 那么比如说, x<-ts.plot(rnorm(10,0,1)) # would like to visually identify the data point indices easily through arrow labelling x使用软件包TeachingDemos中的my.symbols获取指向所需位置的箭头: require(TeachingDemos) d <- rnorm(10,0,1) plot(d, t

我希望用索引标记数据点——通过目视检查轻松识别索引号

那么比如说,

x<-ts.plot(rnorm(10,0,1)) # would like to visually identify the data point indices easily through arrow labelling

x使用软件包
TeachingDemos
中的
my.symbols
获取指向所需位置的箭头:

require(TeachingDemos)
d <- rnorm(10,0,1)
plot(d, type="l", ylim=c(min(d)-1, max(d)+1))
my.symbols(x=1:10, y=d, ms.arrows, angle=pi/2, add=T, symb.plots=TRUE, adj=1.5)
require(教学演示)
d您可以为此使用
text()

n <- 10
d <- rnorm(n)
plot(d, type="l", ylim=c(min(d)-1, max(d)+1))
text(1:n, d+par("cxy")[2]/2,col=2) # Upside
text(1:n, d-par("cxy")[2]/2,col=3) # Downside

n您可以使用
箭头
功能:

set.seed(1); ts.plot(x <-rnorm(10,0,1), ylim=c(-1.6,1.6))  # some random data
arrows(x0=1:length(x), y0=0, y1=x, code=2, col=2, length=.1) # adding arrows
text(x=1:10, y=x+.1, 0, labels=round(x,2), cex=0.65) # adding text
abline(h=0) # adding a horizontal line at y=0

set.seed(1);t.plot(x此处为
lattice
版本,以查看某些基本函数的相似性

set.seed(1234)
dat = data.frame(x=1:10, y = rnorm(10,0,1))
xyplot(y~x,data=dat, type =c('l','p'),
       panel = function(x,y,...){
         panel.fill(col=rgb(1,1,0,0.5))
         panel.xyplot(x,y,...)
         panel.arrows(x, y0=0,x1=x, y1=y, code=2, col=2, length=.1)
         panel.text(x,y,label=round(y,2),adj=1.2,cex=1.5)
         panel.abline(a=0)

       })

感谢所有的答案!谢谢大家的投票