How can I add labels in a plot where I've used the function plot
and points
?
I have the following code
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)
And the display is
I would like to indicate with labels this is prior and this is posterior .Also indicating which parameters are being used.
I know how to add labels when you only use plot(x,y,xlab="y axis")
but not when combined with points
also this form of labeled would not be that clear in the plot.
The labels not in the usual form as is x and y labels in the plot, but indicating inside the plot, this is the prior and this the posterior.
Could you please help?
Thank you in advance.
By the comment of @Chase,
Using the function text()
.
Example:
text(x = .2, y = 5, label = "Posterior distribution")
.