File: ggraph.Rd

package info (click to toggle)
r-cran-ggraph 2.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,648 kB
  • sloc: cpp: 1,219; makefile: 2
file content (133 lines) | stat: -rw-r--r-- 6,718 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ggraph.R, R/layout.R, R/tbl_graph.R
\name{ggraph}
\alias{ggraph}
\alias{create_layout}
\alias{layout_ggraph}
\alias{create_layout.default}
\alias{create_layout.layout_ggraph}
\alias{create_layout.tbl_graph}
\alias{layout_tbl_graph}
\title{Create a ggraph plot}
\usage{
ggraph(graph, layout = "auto", ...)

create_layout(graph, layout, circular, ...)

\method{create_layout}{default}(graph, layout, ...)

\method{create_layout}{layout_ggraph}(graph, ...)

\method{create_layout}{tbl_graph}(graph, layout, circular = FALSE, ...)
}
\arguments{
\item{graph}{The object containing the graph. See \emph{Details} for a list
of supported classes. Or a \code{layout_ggraph} object as returned from
\code{create_layout} in which case all subsequent arguments is ignored.}

\item{layout}{The type of layout to create. Either a valid string, a
function, a matrix, or a data.frame (see Details)}

\item{...}{Arguments passed on to the layout function.}

\item{circular}{Should the layout be transformed into a radial
representation. Only possible for some layouts. Defaults to \code{FALSE}}
}
\value{
For \code{ggraph()} an object of class gg onto which layers, scales,
etc. can be added. For \code{create_layout()} an object inheriting from
\code{layout_ggraph}. \code{layout_ggraph} itself inherits from
\code{data.frame} and can be considered as such. The data.frame contains
the node positions in the \code{x} and \code{y} column along with
additional columns generated by the specific layout, as well as node
parameters inherited from the graph. Additional information is stored as
attributes to the data.frame. The original graph object is stored in the
\code{graph} attribute and the \code{circular} attribute contains a logical
indicating whether the layout has been transformed to a circular
representation.
}
\description{
This function is the equivalent of \code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} in ggplot2.
It takes care of setting up the plot object along with creating the layout
for the plot based on the graph and the specification passed in.
Alternatively a layout can be prepared in advance using
\code{create_layout} and passed as the data argument. See \emph{Details} for
a description of all available layouts.
}
\details{
Following is a short description of the different layout types available in
ggraph. Each layout is further described in its own help pages. Any type of
regular graph/network data can be represented as a tbl_graph object. Because
of this the different layouts that can be applied to tbl_graph
objects are quite diverse, but not all layouts makes sense to all types of
graphs. It is up to the user to understand their data and choose an
appropriate layout. For standard node-edge diagrams igraph defines a
long range of different layout functions that are all available through the
\code{igraph} layout where the specific layout is specified using the
\code{algorithm} argument. In order to minimize typing all igraph algorithms
can also be passed directly into the \code{layout} argument.

Any object that has an appropriate \code{as_tbl_graph} method can be passed
into \code{ggraph()} and will automatically be converted underneath.

\describe{
\item{\code{auto}}{The default layout. See \code{\link[=layout_tbl_graph_auto]{layout_tbl_graph_auto()}} for further
details}
\item{\code{igraph}}{Use one of the internal igraph layout algorithms.
The algorithm is specified using the \code{algorithm} argument. All strings
accepted by the \code{algorithm} argument can also be supplied directly
into \code{layout}. See \code{\link[=layout_tbl_graph_igraph]{layout_tbl_graph_igraph()}} for further
details}
\item{\code{dendrogram}}{Lays out the nodes in a tree-like graph as a
dendrogram with leaves set at 0 and parents 1 unit above its tallest child.
See \code{\link[=layout_tbl_graph_dendrogram]{layout_tbl_graph_dendrogram()}} for further details}
\item{\code{manual}}{Lets the user manually specify the location of each
node. See \code{\link[=layout_tbl_graph_manual]{layout_tbl_graph_manual()}} for further details}
\item{\code{linear}}{Arranges the nodes linearly or circularly in order to
make an arc diagram. See \code{\link[=layout_tbl_graph_linear]{layout_tbl_graph_linear()}} for further
details}
\item{\code{matrix}}{Arranges nodes on a diagonal thus preparing it for use with
\code{\link[=geom_edge_point]{geom_edge_point()}} to make a matrix plot. See \code{\link[=layout_tbl_graph_matrix]{layout_tbl_graph_matrix()}}
for further details}
\item{\code{treemap}}{Creates a treemap from the graph, that is, a
space-filing subdivision of rectangles showing a weighted hierarchy. See
\code{\link[=layout_tbl_graph_treemap]{layout_tbl_graph_treemap()}} for further details}
\item{\code{circlepack}}{Creates a layout showing a hierarchy as circles
within circles. Conceptually equal to treemaps. See
\code{\link[=layout_tbl_graph_circlepack]{layout_tbl_graph_circlepack()}} for further details}
\item{\code{partition}}{Create icicle or sunburst charts, where each layer
subdivides the division given by the preceding layer. See
\code{\link[=layout_tbl_graph_partition]{layout_tbl_graph_partition()}} for further details}
\item{\code{hive}}{Positions nodes on axes spreading out from the center
based on node attributes. See \code{\link[=layout_tbl_graph_hive]{layout_tbl_graph_hive()}} for further
details}
}

Alternatively a matrix or a data.frame can be provided to the \code{layout}
argument. In the former case the first column will be used as x coordinates
and the second column will by used as y coordinates, further columns are
dropped. In the latter case the data.frame is used as the layout table and
must thus contain a numeric x and y column.

Lastly a function can be provided to the \code{layout} argument. It will be called
with the graph object as its first argument and any additional argument
passed into \code{ggraph()}/\code{create_layout()}. The function must return either a
data.frame or an object coercible to one and have an \code{x} and \code{y} column, or
an object coercible to a \code{tbl_graph}. In the latter case the node data is
extracted and used as layout (and must thus contain an \code{x} and \code{y} column)
and the graph will be added as the \code{graph} attribute.
}
\examples{
require(tidygraph)
gr <- create_notable('bull')
layout <- create_layout(gr, layout = 'igraph', algorithm = 'kk')
}
\seealso{
\code{\link[=get_edges]{get_edges()}} for extracting edge information from the
layout and \code{\link[=get_con]{get_con()}} for extracting path information.
}
\keyword{graph}
\keyword{hierarchy}
\keyword{layout}
\keyword{network}
\keyword{visualisation}