locate_vertex | R Documentation |
This function is a wrapper of grid::grid.locator()
, and provides a way to
find the coordinates of a vertex in the current plot. It is useful to
identify the vertex that is being clicked in a plot.
locate_vertex(x = NULL)
x |
An object of class |
This function only works in interactive mode. Once it is called,
the user can click on a vertex in the plot. The function will return the
name of the vertex, the x and y coordinates and the viewport where it is
located. If x
is not specified, the last plotted netplot
object will be
used.
A list with the name of the vertex, the x and y coordinates and the viewport where it is located.
library(igraph)
library(netplot)
set.seed(1)
x <- sample_smallworld(1, 200, 5, 0.03)
# Plotting
nplot(x)
# Clicking (only works in interactive mode)
if (interactive()) {
res <- locate_vertex()
print(res)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.