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)

Arguments

x

An object of class netplot

Value

A list with the name of the vertex, the x and y coordinates and the viewport where it is located.

Details

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.

Examples

#> #> Attaching package: ‘igraph’
#> The following object is masked from ‘package:netplot’: #> #> ego
#> The following objects are masked from ‘package:stats’: #> #> decompose, spectrum
#> The following object is masked from ‘package:base’: #> #> union
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) }