Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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
如何使固定的'text()'的大小与R中移动的'text()'的大小相同_R_Function_Plot - Fatal编程技术网

如何使固定的'text()'的大小与R中移动的'text()'的大小相同

如何使固定的'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

如果您运行下面的小函数,您将看到如下图所示的内容。 较小的此处”在曲线周围是固定的。但是如果您多次运行我的函数,较大的“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.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