R Graph Naming Points

I would like to name some points of the graph R obtained from the main graph of the function ().

More precisely, I have a two-dimensional parametric function t → (a (t), b (t)), and I will construct points (a (t), b (t)). I would like to print the value of t corresponding to each point.

thank

+3
source share
3 answers

You can use text () as shown below:

 set.seed(10)
 x = rnorm(10)
 y = rnorm(10)

plot(y~x, pch = ".", cex = 2)
text(x, y, 
    label = paste("(", round(x, 1), ", ", round(y, 1), ")", sep = ""), 
    cex = 0.6)

If you do not need all the points, just send some of them to the text ().

+5
source

I don’t dig out the expression t -> (a(t),b(t))... nevermind, I realized that you want to display values ​​instead of character plots. Here:

# I'll steal shamelessly Greg code
plot(x, y, pch = "")
# then do the text() part...

However, I recommend doing this with ggplot2:

ggplot(mtcars, aes(mpg, hp)) + geom_text(aes(label = rownames(mtcars)))

, , - .

+1

,

" 2- t → (a (t), b (t)) (a (t), b (t)). t ."

The following example shows how a pair of parametric functions can be used to locate points, as well as a function argument:

t <- seq(0,1.75,by=0.25)*pi
plot(cos(t),sin(t))
text(cos(t),sin(t),labels=round(t,2), ## location and text
     pos = 1,offset=0.4) ## text is placed below the specified locations
0
source

Source: https://habr.com/ru/post/1752108/


All Articles