Volver al ranking

thomasp85/ggraph

Rggraph.data-imaginist.com

Grammar of Graph Graphics

graph-visualizationggplot2visualizationnetwork-visualizationrggplot-extension
Crecimiento de estrellas
Estrellas
1.1k
Forks
114
Crecimiento semanal
Issues
50
5001k
ene 2016jul 2019ene 2023jul 2026
README

ggraph

R-CMD-check CRAN_Release_Badge CRAN_Download_Badge Codecov test
coverage

/dʒiː.dʒɪˈrɑːf/ (or g-giraffe)

A grammar of graphics for relational data

ggraph is an extension of ggplot2 aimed at supporting relational data structures such as networks, graphs, and trees. While it builds upon the foundation of ggplot2 and its API it comes with its own self-contained set of geoms, facets, etc., as well as adding the concept of layouts to the grammar.

An example

library(ggraph)
#> Loading required package: ggplot2
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter

# Create graph of highschool friendships
graph <- as_tbl_graph(highschool) |> 
    mutate(Popularity = centrality_degree(mode = 'in'))

# plot using ggraph
ggraph(graph, layout = 'kk') + 
    geom_edge_fan(aes(alpha = after_stat(index)), show.legend = FALSE) + 
    geom_node_point(aes(size = Popularity)) + 
    facet_edges(~year) + 
    theme_graph(foreground = 'steelblue', fg_text_colour = 'white')

The core concepts

ggraph builds upon three core concepts that are quite easy to understand:

  1. The Layout defines how nodes are placed on the plot, that is, it is a conversion of the relational structure into an x and y value for each node in the graph. ggraph has access to all layout functions available in igraph and furthermore provides a large selection of its own, such as hive plots, treemaps, and circle packing.
  2. The Nodes are the connected entities in the relational structure. These can be plotted using the geom_node_*() family of geoms. Some node geoms make more sense for certain layouts, e.g. geom_node_tile() for treemaps and icicle plots, while others are more general purpose, e.g. geom_node_point().
  3. The Edges are the connections between the entities in the relational structure. These can be visualized using the geom_edge_*() family of geoms that contain a lot of different edge types for different scenarios. Sometimes the edges are implied by the layout (e.g. with treemaps) and need not be plotted, but often some sort of line is warranted.

All of the tree concepts have been discussed in detail in dedicated blog posts that are also available as vignettes in the package. Please refer to these for more information.

Note: The linked blog posts are based on ggraph v1. After ggraph v1.1 the underlying implementation was moved to tidygraph and cleaned up, but this resulted in some breaking changes in the process. Therefore the vignette versions are generally recommended as they have been updated.

Supported data types

There are many different ways to store and work with relational data in R. ggraph is built upon tidygraph and the large swath of data structures it supports are thus natively supported in ggraph. In order to get a data type supported by ggraph, simply provide an as_tbl_graph method for it.

Installation

ggraph is available through CRAN and can be installed with install.packages('ggraph'). The package is under active development though and the latest set of features can be obtained by installing from this repository using devtools

# install.packages("pak")
pak::pak('thomasp85/ggraph')

ggraph is not the only package to provide some sort of support for relational data in ggplot2, though I’m fairly certain that it is the most ambitious. ggdendro provides support for dendrogram and hclust objects through conversion of the structures into line segments that can then be plotted with geom_segment(). ggtree provides more extensive support for all things tree-related, though it lacks some of the layouts and edge types that ggraph offers (it has other features that ggraph lacks though). For more standard hairball network plots ggnetwork, geomnet, and GGally all provide some functionality though none of them are as extensive in scope as ggraph.

Code of Conduct

Please note that the ‘ggraph’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Repositorios relacionados
DeusData/codebase-memory-mcp

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

CMIT Licenseclaude-codecode-analysis
deusdata.github.io/codebase-memory-mcp/
33.8k2.6k
networkx/networkx

Network Analysis in Python

PythonPyPIOtherpythoncomplex-networks
networkx.org
17.1k3.6k
antvis/G6

♾ A Graph Visualization Framework in JavaScript.

TypeScriptnpmMIT Licensegraph-drawingtree
g6.antv.antgroup.com
12.2k1.6k
graphistry/pygraphistry

PyGraphistry is a Python library to quickly load, shape, embed, and explore big graphs with the GPU-accelerated Graphistry visual graph analyzer

PythonPyPIBSD 3-Clause "New" or "Revised" Licensegraphvisualization
2.5k231
dominikbraun/graph

A library for creating generic graph data structures and modifying, analyzing, and visualizing them.

GoGo ModulesApache License 2.0graphgraph-algorithms
dominik.info/graph
2.2k114
neo4j-contrib/neovis.js

Neo4j + vis.js = neovis.js. Graph visualizations in the browser with data from Neo4j.

TypeScriptnpmApache License 2.0neo4jvisualization
1.8k327
eisman/neo4jd3

Neo4j graph visualization using D3.js

JavaScriptnpmMIT Licenseneo4jd3
eisman.github.io/neo4jd3/
1.5k423
cneben/QuickQanava

:link: C++17 network / graph visualization library - Qt6 / QML node editor.

C++Othergraphdataflow-programming
cneben.github.io/QuickQanava/index.html
1.4k252
glato/emerge

Emerge is a browser-based interactive codebase and dependency visualization tool for many different programming languages. It supports some basic code quality and graph metrics and provides a simple and intuitive way to explore and analyze a codebase by using graph structures.

PythonPyPIMIT Licensevisualizationgraph-visualization
1.1k82
antvis/Graphin

🌌 A React toolkit for graph visualization based on G6.

TypeScriptnpmMIT Licensegraph-analysisg6
github.com/antvis/graphin
1.1k275
reaviz/reagraph

🕸 WebGL Graph Visualizations for React. Maintained by @goodcodeus.

TypeScriptnpmApache License 2.0reactwebgl
reagraph.dev
1.1k94