function - How to make the size of fixed `text()` to mach the size of a moving `text()` in R -


if run small function below, you'll see below picture. smaller-sized "here" fixed around curve. larger-sized "here" moving if run function multiple times (see r code further below).

my question how can have size of fixed "here" text() become equal size of moving text() only when 2 pieces of text fall on top of each other?

please see annotated r code below.

enter image description here

here = function(){  curve(dnorm(x), -4, 4)  x.on.curve = seq(-4, 4, len = 21) # x.values fixed text y.on.curve = dnorm(x.on.curve)    # y.values fixed text  xx  <- sample(x = seq(-4, 4, len = 21), size = 1) # x.values moving text yy  <- dnorm(xx)                                  # y.values moving text  text(x.on.curve, y.on.curve, 'here') ## whenever x.values of fixed 'here'                                        # matches x.value of moving 'here'                                         # in below "text()", change cex = 2, else cex = 1  text(xx, yy, 'here', cex = 2)           }  ## please run multiple times here: here() 

would work?

here = function(){        curve(dnorm(x), -4, 4)    x.on.curve = seq(-4, 4, len = 21) # x.values fixed text    y.on.curve = dnorm(x.on.curve)    # y.values fixed text     ind <- sample(1:21,1) # index of x , y values 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() 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -