locate_vertex: Find a vertex in the current plot

View source: R/netplot.R

locate_vertexR Documentation

Find a vertex in the current plot

Description

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.

Usage

locate_vertex(x = NULL)

Arguments

x

An object of class netplot

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.

Value

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

Examples

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)
}


netplot documentation built on July 1, 2024, 1:06 a.m.