Plot Construction

While ggraph builds on top of ggplot2 it uses its own function to initialise plots, allowing you to set global settings such as layouts etc.

ggraph() create_layout()

Create a ggraph plot

autograph()

Quickplot wrapper for networks

Layouts

Layouts specify the spatial positioning of the nodes in the graph. In addition to calculating x and y coordinates for the nodes some layouts also calculate additional metrics used when plotting, e.g. width and height for treemap layouts. Layouts are specified in the ggraph() call or precalculated using create_layout().

layout_tbl_graph_auto()

Automatically pick a layout based on graph type

layout_tbl_graph_manual()

Manually specify a layout for layout_tbl_graph

layout_tbl_graph_stress() layout_tbl_graph_sparse_stress()

Place nodes using stress majorisation

layout_tbl_graph_igraph()

Use igraph layout algorithms for layout_tbl_graph

layout_tbl_graph_backbone()

Place node to emphasize group structure

layout_tbl_graph_pmds()

Place nodes based on a multidimensional scaling of a set of pivot nodes

layout_tbl_graph_eigen()

Place nodes according to their eigenvalues

layout_tbl_graph_centrality()

Place nodes in circles according to centrality measure

layout_tbl_graph_focus()

Place nodes in circles based on distance to a specific node

layout_tbl_graph_dendrogram()

Apply a dendrogram layout to layout_tbl_graph

layout_tbl_graph_unrooted()

Create an unrooted layout using equal-angle or equal-daylight

layout_tbl_graph_linear()

Place nodes on a line or circle

layout_tbl_graph_circlepack()

Calculate nodes as circles packed within their parent circle

layout_tbl_graph_treemap()

Calculate nodes as rectangles subdividing that of their parent

layout_tbl_graph_partition()

Calculate nodes as areas dividing their parent

layout_tbl_graph_cactustree()

Calculate nodes as fractal circle buds

layout_tbl_graph_htree()

Layout binary trees in a fractal H formation

layout_tbl_graph_matrix()

Place nodes on a diagonal

layout_tbl_graph_hive()

Place nodes in a Hive Plot layout

layout_tbl_graph_fabric() node_rank_fabric()

Create a fabric layout

layout_tbl_graph_sf()

Place nodes on their geographical space

layout_tbl_graph_metro()

Place nodes according to the standard design of metro maps

Nodes

While nodes are often thought of as points in a hairball graph, they are much more than that, depending on the layout type.

geom_node_point()

Show nodes as points

geom_node_text() geom_node_label()

Annotate nodes with text

geom_node_tile()

Draw the rectangles in a treemap

geom_node_voronoi()

Show nodes as voronoi tiles

geom_node_circle()

Show nodes as circles

geom_node_arc_bar()

Show nodes as thick arcs

geom_node_range()

Show nodes as a line spanning a horizontal range

geom_node_sf()

Show nodes as POINTs in geographical space

Edges

Edges are the entities connecting nodes, often drawn with some sort of line. Certain layouts calls for other types, e.g. a matrix plot where edges are illustrated with points.

geom_edge_link() geom_edge_link2() geom_edge_link0()

Draw edges as straight lines between nodes

geom_edge_arc() geom_edge_arc2() geom_edge_arc0()

Draw edges as Arcs

geom_edge_parallel() geom_edge_parallel2() geom_edge_parallel0()

Draw multi edges as parallel lines

geom_edge_fan() geom_edge_fan2() geom_edge_fan0()

Draw edges as curves of different curvature

geom_edge_loop() geom_edge_loop0()

Draw edges as diagonals

geom_edge_diagonal() geom_edge_diagonal2() geom_edge_diagonal0()

Draw edges as diagonals

geom_edge_elbow() geom_edge_elbow2() geom_edge_elbow0()

Draw edges as elbows

geom_edge_bend() geom_edge_bend2() geom_edge_bend0()

Draw edges as diagonals

geom_edge_hive() geom_edge_hive2() geom_edge_hive0()

Draw edges in hive plots

geom_edge_span() geom_edge_span2() geom_edge_span0()

Draw edges as vertical spans

geom_edge_point()

Draw edges as glyphs

geom_edge_tile()

Draw edges as glyphs

geom_edge_density()

Show edges as a density map

geom_edge_bundle_force() geom_edge_bundle_force2() geom_edge_bundle_force0()

Bundle edges using force directed edge bundling

geom_edge_bundle_path() geom_edge_bundle_path2() geom_edge_bundle_path0()

Bundle edges using edge path bundling

geom_edge_bundle_minimal() geom_edge_bundle_minimal2() geom_edge_bundle_minimal0()

Bundle edges along the minimal spanning tree

geom_edge_sf()

Draw edges as LINESTRINGs in geographical space

Connections

Connections are meta-edges, connecting nodes that are not direct neighbors, either through their shortest path or directly.

geom_conn_bundle() geom_conn_bundle2() geom_conn_bundle0()

Create hierarchical edge bundles between node connections

Facets

Faceting with networks is a bit different than for tabular data, as you’d often want to facet only nodes, or edges etc.

facet_graph()

Create a grid of small multiples by node and/or edge attributes

facet_nodes()

Create small multiples based on node attributes

facet_edges()

Create small multiples based on edge attributes

Scales

While nodes uses the standard scales provided by ggplot2, edges have their own, allowing you to have different scaling for nodes and edges.

scale_edge_colour_hue() scale_edge_colour_brewer() scale_edge_colour_distiller() scale_edge_colour_gradient() scale_edge_colour_gradient2() scale_edge_colour_gradientn() scale_edge_colour_grey() scale_edge_colour_identity() scale_edge_colour_manual() scale_edge_colour_viridis() scale_edge_colour_steps() scale_edge_colour_steps2() scale_edge_colour_stepsn() scale_edge_colour_fermenter() scale_edge_colour_continuous() scale_edge_colour_discrete() scale_edge_colour_binned() scale_edge_color_hue() scale_edge_color_brewer() scale_edge_color_distiller() scale_edge_color_gradient() scale_edge_color_gradient2() scale_edge_color_gradientn() scale_edge_color_grey() scale_edge_color_identity() scale_edge_color_manual() scale_edge_color_continuous() scale_edge_color_discrete() scale_edge_color_viridis() scale_edge_color_steps() scale_edge_color_steps2() scale_edge_color_stepsn() scale_edge_color_fermenter() scale_edge_color_binned()

Edge colour scales

scale_edge_fill_hue() scale_edge_fill_brewer() scale_edge_fill_distiller() scale_edge_fill_gradient() scale_edge_fill_gradient2() scale_edge_fill_gradientn() scale_edge_fill_grey() scale_edge_fill_identity() scale_edge_fill_manual() scale_edge_fill_viridis() scale_edge_fill_steps() scale_edge_fill_steps2() scale_edge_fill_stepsn() scale_edge_fill_fermenter() scale_edge_fill_continuous() scale_edge_fill_discrete() scale_edge_fill_binned()

Edge fill scales

scale_edge_alpha() scale_edge_alpha_continuous() scale_edge_alpha_discrete() scale_edge_alpha_binned() scale_edge_alpha_manual() scale_edge_alpha_identity()

Edge alpha scales

scale_edge_width_continuous() scale_edge_width() scale_edge_width_discrete() scale_edge_width_binned() scale_edge_width_manual() scale_edge_width_identity()

Edge width scales

scale_edge_size_continuous() scale_edge_radius() scale_edge_size() scale_edge_size_discrete() scale_edge_size_binned() scale_edge_size_area() scale_edge_size_binned_area() scale_edge_size_manual() scale_edge_size_identity()

Edge size scales

scale_edge_linetype() scale_edge_linetype_continuous() scale_edge_linetype_discrete() scale_edge_linetype_binned() scale_edge_linetype_manual() scale_edge_linetype_identity()

Edge linetype scales

scale_edge_shape() scale_edge_shape_discrete() scale_edge_shape_continuous() scale_edge_shape_binned() scale_edge_shape_manual() scale_edge_shape_identity()

Edge shape scales

scale_label_size_continuous() scale_label_size() scale_label_size_discrete() scale_label_size_binned() scale_label_size_manual() scale_label_size_identity()

Edge label size scales

Guides

As for scales, the edge geoms comes with their own guides.

guide_edge_direction()

Edge direction guide

guide_edge_colourbar() guide_edge_colorbar()

Colourbar legend for edges

guide_edge_coloursteps() guide_edge_colorsteps()

Coloursteps legend for edges

Helpers

ggraph contains an assortment of helpers for various tasks related to plotting.

geom_axis_hive()

Draw rectangular bars and labels on hive axes

get_sf_nodes() get_nodes()

Create a node extractor function

get_edges() get_sf_edges()

Create edge extractor function

get_con()

Create a connection extractor function

geometry() circle() square() ellipsis() rectangle() label_rect() is.geometry()

Define simple shapes for line capping

node_angle() edge_angle()

Get the angle of nodes and edges

pack_circles()

Pack circles together

theme_graph() th_foreground() th_no_axes() set_graph_style() unset_graph_style()

A theme tuned for graph visualizations

Data

To facilitate playing around ggraph includes a set of small network datasets

flare

The class hierarchy of the flare visualization library

highschool

Friendship among high school boys

whigs

Membership network of American Whigs