plot.grapherator: Visualize graph.

Description Usage Arguments Value Examples

View source: R/plot.R

Description

plot.grapherator generates a scatterplot of the nodes in the Euclidean plane. Additionally, the edge weights are visualized. In case of one weight per edge either a histogram or an empirical distribution function is drawn. For graphs with two weights per edge a scatterplot is used.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'grapherator'
plot(
  x,
  y = NULL,
  show.cluster.centers = TRUE,
  highlight.clusters = FALSE,
  show.edges = TRUE,
  weight.plot.type = "histogram",
  ...
)

Arguments

x

[grapherator]
Graph.

y

Not used at the moment.

show.cluster.centers

[logical(1)]
Display cluster centers? Default is TRUE. This option is ignored silently if the instance is not clustered.

highlight.clusters

[logical(1)]
Shall nodes be coloured by cluster membership? Default is FALSE.

show.edges

[logical(1)]
Display edges? Keep in mind, that the number of edges is O(n^2) where n is the number of nodes. Default is TRUE.

weight.plot.type

[character(1)]
Type of visualization which should be used for weights in case x has only as single weight attached to each edge. Either “histogram” or “ecdf” (empirical distribution function) are possible choices. Default is histogram.

...

[any]
Not used at the moment.

Value

[list] A list of ggplot objects with components pl.weights (scatterplot of edge weights) and eventually pl.coords (scatterplot of nodes). The latter is NULL, if graph has no associated coordinates.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
g = graph(0, 100)
g = addNodes(g, n = 25, generator = addNodesGrid)
g = addEdges(g, generator = addEdgesDelauney)
g = addWeights(g, generator = addWeightsDistance, method = "manhattan")
## Not run: 
pls = plot(g, weight.plot.type = "ecdf")

## End(Not run)

g = addWeights(g, generator = addWeightsRandom,
  method = rpois, lambda = 0.1)
## Not run: 
pls = plot(g, show.edges = FALSE)

## End(Not run)

g = graph(0, 100)
g = addNodes(g, n = 25, generator = addNodesGrid)
g = addNodes(g, n = 9, by.centers = TRUE, generator = addNodesGrid,
  lower = c(0, 0), upper = c(7, 7))
g = addEdges(g, generator = addEdgesDelauney)
g = addWeights(g, generator = addWeightsCorrelated, rho = -0.8)
## Not run: 
do.call(gridExtra::grid.arrange, plot(g, show.edges = FALSE))
do.call(gridExtra::grid.arrange, plot(g, show.edges = TRUE,
  show.cluster.centers = FALSE))

## End(Not run)

jakobbossek/grapherator documentation built on Oct. 4, 2021, 11:03 a.m.