graphModplot: Graph Plot Editor

View source: R/graphModplot.R

graphModplotR Documentation

Graph Plot Editor

Description

Interactively modify the plot of a graph object by manually changing the location where vertices are being placed.

Usage

graphModplot(
  x,
  col = "grey80",
  bg = c("red", "black", "blue"),
  pch = 21L,
  length = 0.05,
  pt.cex = 0.75,
  ...
)

Arguments

x

A graph-class object.

col

Color of the arrows representing the edges. Default is "grey80".

bg

Background colors for the origin, intermediate, and terminal vertices, respectively. Default is c("red","black","blue").

pch

Plotting 'character' (see points) for the details. Default is 21 (a solid dot with a colored background).

length

Length of the edge of the arrow head (see arrows). The default value is 0.05.

pt.cex

The relative point size used for the vertex markers. The default value is 0.75.

...

Additional parameters to be passed to other functions of methods.

Details

After calling the function, a mouse-click on the display will select the nearest vertex. Which one has been selected is indicated by the background of its marker turning white, with its incoming edges appearing as red dashed segments and its outgoing edges appearing as blue dashed segments. A second mouse-click will cause the vertex to be relocated at the location of the mouse pointer.

Value

A point geometry object.

Author(s)

Guillaume Guénard [aut, cre] (<https://orcid.org/0000-0003-0761-3072>), Pierre Legendre [ctb] (<https://orcid.org/0000-0002-3838-3305>) Maintainer: Guillaume Guénard <guillaume.guenard@umontreal.ca>

See Also

graph-class.

Examples

## Create an exemplary graph:
data.frame(
  species = rep(TRUE,13),
  type = c(2,2,3,1,2,2,2,2,2,2,3,3,3),
  x = c(1,3,4,0,1.67,4,1,1.33,2.33,3.33,4.33,4,5),
  y = c(1,1,1,0,0.5,0,-1,0,0,-0.5,-1,-0.5,-0.5),
  row.names = sprintf("V%d",1:13)
) %>%
  st_as_sf(
    coords=c("x","y"),
    crs = NA
  ) %>%
  graph %>%
  add.edge(
    from = c(1,2,1,5,4,4,5,9,4,8,9,4,7,7,6,6,9,10,10),
    to = c(2,3,5,2,1,5,9,2,8,9,6,7,8,9,3,13,10,12,11),
    data = data.frame(
      distance = c(4.2,4.7,3.9,3.0,3.6,2.7,4.4,3.4,3.6,3.3,
                   4.8,3.2,3.5,4.4,2.5,3.4,4.3,3.1,2.2),
      row.names = sprintf("E%d",1:19)
    )
  ) -> x

## Original coordinates:
plot(x)

## Edit the vertex locations manually:
x <- graphModplot(x)

## Plot with the new coordinates
plot(x)



guenardg/MPSEM documentation built on April 14, 2025, 3:53 p.m.