如何在使用函数“plot”和“points”的绘图中添加标签?
How can I add labels in a plot where I've used the function `plot` and `points`?
如何在使用函数 plot
和 points
的绘图中添加标签?
我有以下代码
x<-seq(0,1,.01)
alpha=2
beta=3
y<-dbeta(x,alpha,beta)
plot(x,y,ylim=c(0,5.9))
n=10
y1<-dbeta(x,alpha+x,beta+n-x)
points(x,y1)
显示为
我想用标签表示这是先验的和这是后验的。同时指出正在使用哪些参数。
我知道如何在你只使用 plot(x,y,xlab="y axis")
时添加标签
但与 points
结合使用时,这种形式的标记在情节中也不会那么清晰。
标签不像图中的 x 和 y 标签那样采用通常的形式,而是在图中指示,这是 the prior and this the后。
你能帮忙吗?
提前谢谢你。
根据@Chase的评论,
使用函数text()
.
示例:
text(x = .2, y = 5, label = "Posterior distribution")
.
如何在使用函数 plot
和 points
的绘图中添加标签?
我有以下代码
x<-seq(0,1,.01)
alpha=2
beta=3
y<-dbeta(x,alpha,beta)
plot(x,y,ylim=c(0,5.9))
n=10
y1<-dbeta(x,alpha+x,beta+n-x)
points(x,y1)
显示为
我想用标签表示这是先验的和这是后验的。同时指出正在使用哪些参数。
我知道如何在你只使用 plot(x,y,xlab="y axis")
但与 points
结合使用时,这种形式的标记在情节中也不会那么清晰。
标签不像图中的 x 和 y 标签那样采用通常的形式,而是在图中指示,这是 the prior and this the后。
你能帮忙吗?
提前谢谢你。
根据@Chase的评论,
使用函数text()
.
示例:
text(x = .2, y = 5, label = "Posterior distribution")
.