如何使固定的'text()'的大小与R中移动的'text()'的大小相同
如果您运行下面的小函数,您将看到如下图所示的内容。 较小的“此处”在曲线周围是固定的。但是如果您多次运行我的函数,较大的“Here”正在移动(请参阅下面的R代码) 我的问题是如何使固定的“HERE”如何使固定的'text()'的大小与R中移动的'text()'的大小相同,r,function,plot,R,Function,Plot,如果您运行下面的小函数,您将看到如下图所示的内容。 较小的“此处”在曲线周围是固定的。但是如果您多次运行我的函数,较大的“Here”正在移动(请参阅下面的R代码) 我的问题是如何使固定的“HERE”text()的大小与移动的text()的大小相等,只有当这两段文本相互重叠时才可以 请参阅下面我的带注释的R代码。 Here=function(){ 曲线(dnorm(x),-4,4) x、 on.curve=seq(-4,4,len=21)#x.固定文本的值 y、 on.curve=dnorm(x
text()
的大小与移动的text()
的大小相等,只有当这两段文本相互重叠时才可以
请参阅下面我的带注释的R代码。
Here=function(){
曲线(dnorm(x),-4,4)
x、 on.curve=seq(-4,4,len=21)#x.固定文本的值
y、 on.curve=dnorm(x.on.curve)#y.固定文本的值
xx你喜欢这项工作吗
Here = function(){
curve(dnorm(x), -4, 4)
x.on.curve = seq(-4, 4, len = 21) # x.values for fixed text
y.on.curve = dnorm(x.on.curve) # y.values for fixed text
ind <- sample(1:21,1) # index of the x and y values for moving text
text(x.on.curve[-ind], y.on.curve[-ind], 'Here')
text(x.on.curve[ind], y.on.curve[ind], 'Here', cex = 2)
}
## Please run multiple times here:
Here()
Here=function(){
曲线(dnorm(x),-4,4)
x、 on.curve=seq(-4,4,len=21)#x.固定文本的值
y、 on.curve=dnorm(x.on.curve)#y.固定文本的值
你喜欢这项工作吗
Here = function(){
curve(dnorm(x), -4, 4)
x.on.curve = seq(-4, 4, len = 21) # x.values for fixed text
y.on.curve = dnorm(x.on.curve) # y.values for fixed text
ind <- sample(1:21,1) # index of the x and y values for moving text
text(x.on.curve[-ind], y.on.curve[-ind], 'Here')
text(x.on.curve[ind], y.on.curve[ind], 'Here', cex = 2)
}
## Please run multiple times here:
Here()
Here=function(){
曲线(dnorm(x),-4,4)
x、 on.curve=seq(-4,4,len=21)#x.固定文本的值
y、 on.curve=dnorm(x.on.curve)#y.固定文本的值
ind