Create a ggraph plot

This function is the equivalent of 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 create_layout and passed as the data argument. See Details for a desciption of all available layouts.

graph, network, visualisation, layout, hierarchy
ggraph(graph, layout = "auto", ...)
create_layout(graph, layout, circular, ...)
"create_layout"(graph, layout, ...)
"create_layout"(graph, layout, circular = FALSE, ...)
"create_layout"(graph, layout, circular = FALSE, ...)
"create_layout"(graph, layout, circular = FALSE, ...)
"create_layout"(graph, layout, circular = FALSE, ...)
The object containing the graph. See Details for a list of supported classes. Or a layout_ggraph object as returned from create_layout in which case all subsequent arguments is ignored.
The type of layout to create.
Arguments passed on to the layout function.
Should the layout be transformed into a radial representation. Only possible for some layouts. Defaults to FALSE

Following is a short description of the different layout types available in ggraph. Each layout is further described in its own help pages.

Dendrogram objects

The dendrogram class is used to store binary tree from e.g. hierarchical clustering. The layouts provided for this class is constrained to tree-like representations. hclust objects are supported through automatic conversion to dendrogram objects and thus supports the same layouts.

Further, if the layouts provided for igraph objects are needed for dendrogram objects den_to_igraph is provided to convert dendrograms to igraph.

igraph objects

Any type of regular graph/network data can be represented as an igraph object. Because of this the different layouts that can be applied to igraph 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 itself defines a long range of different layout functions that are all available through the igraph layout where the specific layout is specified using the algorithm argument. In order to minimize typing all igraph algorithms can also be passed directly into the layout argument. network objects are supported by automatic conversion to igraph objects using network_to_igraph and thus supports the same layouts.


For ggraph() an object of class gg onto which layers, scales, etc. can be added. For create_layout() an object inherting from layout_ggraph. layout_ggraph itself inherits from data.frame and can be considered as such. The data.frame contains the node positions in the x and 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 graph attribute and the circular attribute contains a logical indicating whether the layout has been transformed to a circular representation.

See Also

get_edges for extracting edge information from the layout and get_con for extracting path information.

  • ggraph
  • create_layout
  • layout_ggraph
  • createLayout
  • create_layout.default
  • create_layout.dendrogram
  • layout_dendrogram
  • create_layout.igraph
  • layout_igraph
  • create_layout.hclust
  • layout_hclust
  • layout_network
gr <- make_graph('bull')
layout <- create_layout(gr, layout = 'igraph', algorithm = 'kk')

Documentation reproduced from package ggraph, version 0.1.1, License: GPL-3 + file LICENSE

Community examples

Looks like there are no examples yet.