{"id":13401468,"url":"https://github.com/thomasp85/ggraph","last_synced_at":"2025-05-14T20:04:24.045Z","repository":{"id":41811132,"uuid":"49573605","full_name":"thomasp85/ggraph","owner":"thomasp85","description":"Grammar of Graph Graphics","archived":false,"fork":false,"pushed_at":"2024-03-07T12:53:00.000Z","size":453428,"stargazers_count":1088,"open_issues_count":52,"forks_count":115,"subscribers_count":44,"default_branch":"main","last_synced_at":"2025-04-13T14:04:10.186Z","etag":null,"topics":["ggplot-extension","ggplot2","graph-visualization","network-visualization","r","visualization"],"latest_commit_sha":null,"homepage":"https://ggraph.data-imaginist.com","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasp85.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-01-13T12:52:59.000Z","updated_at":"2025-03-10T23:57:56.000Z","dependencies_parsed_at":"2023-02-12T20:16:23.396Z","dependency_job_id":"bc7cd486-d770-45df-9b2e-505f819afd75","html_url":"https://github.com/thomasp85/ggraph","commit_stats":{"total_commits":331,"total_committers":14,"mean_commits":"23.642857142857142","dds":0.0453172205438066,"last_synced_commit":"febab71076d7cf277cdb79b823f262b626651703"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Fggraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Fggraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Fggraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Fggraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasp85","download_url":"https://codeload.github.com/thomasp85/ggraph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724639,"owners_count":21151561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ggplot-extension","ggplot2","graph-visualization","network-visualization","r","visualization"],"created_at":"2024-07-30T19:01:03.010Z","updated_at":"2025-04-13T14:04:23.890Z","avatar_url":"https://github.com/thomasp85.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\"\n)\n```\n\n# ggraph \u003cimg src=\"man/figures/logo.png\" align=\"right\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/thomasp85/ggraph/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/thomasp85/ggraph/actions/workflows/R-CMD-check.yaml)\n[![CRAN_Release_Badge](http://www.r-pkg.org/badges/version-ago/ggraph)](https://CRAN.R-project.org/package=ggraph)\n[![CRAN_Download_Badge](http://cranlogs.r-pkg.org/badges/ggraph)](https://CRAN.R-project.org/package=ggraph)\n[![Codecov test coverage](https://codecov.io/gh/thomasp85/ggraph/branch/main/graph/badge.svg)](https://app.codecov.io/gh/thomasp85/ggraph?branch=main)\n\u003c!-- badges: end --\u003e\n\n*/dʒiː.dʒɪˈrɑːf/*  (or g-giraffe)\n\n## A grammar of graphics for relational data\nggraph is an extension of [`ggplot2`](https://ggplot2.tidyverse.org) aimed at\nsupporting relational data structures such as networks, graphs, and trees. \nWhile it builds upon the foundation of `ggplot2` and its API it comes with its\nown self-contained set of geoms, facets, etc., as well as adding the concept of \n*layouts* to the grammar.\n\n### An example\n```{r}\nlibrary(ggraph)\nlibrary(tidygraph)\n\n# Create graph of highschool friendships\ngraph \u003c- as_tbl_graph(highschool) |\u003e \n    mutate(Popularity = centrality_degree(mode = 'in'))\n\n# plot using ggraph\nggraph(graph, layout = 'kk') + \n    geom_edge_fan(aes(alpha = after_stat(index)), show.legend = FALSE) + \n    geom_node_point(aes(size = Popularity)) + \n    facet_edges(~year) + \n    theme_graph(foreground = 'steelblue', fg_text_colour = 'white')\n```\n\n### The core concepts\n`ggraph` builds upon three core concepts that are quite easy to understand:\n\n1. [**The Layout**](https://www.data-imaginist.com/2017/ggraph-introduction-layouts/) \ndefines how nodes are placed on the plot, that is, it is a \nconversion of the relational structure into an x and y value for each node in \nthe graph. `ggraph` has access to all layout functions available in `igraph` and\nfurthermore provides a large selection of its own, such as hive plots, treemaps,\nand circle packing.\n2. [**The Nodes**](https://www.data-imaginist.com/2017/ggraph-introduction-nodes/) \nare the connected entities in the relational structure. These \ncan be plotted using the `geom_node_*()` family of geoms. Some node geoms make\nmore sense for certain layouts, e.g. `geom_node_tile()` for treemaps and icicle\nplots, while others are more general purpose, e.g. `geom_node_point()`.\n3. [**The Edges**](https://www.data-imaginist.com/2017/ggraph-introduction-edges/) \nare the connections between the entities in the relational \nstructure. These can be visualized using the `geom_edge_*()` family of geoms \nthat contain a lot of different edge types for different scenarios. Sometimes\nthe edges are implied by the layout (e.g. with treemaps) and need not be plotted,\nbut often some sort of line is warranted.\n\nAll of the tree concepts have been discussed in detail in dedicated blog posts\nthat are also available as vignettes in the package. Please refer to these for \nmore information.\n\n\u003e **Note:** The linked blog posts are based on ggraph v1. After ggraph v1.1 the\nunderlying implementation was moved to tidygraph and cleaned up, but this \nresulted in some breaking changes in the process. Therefore the vignette \nversions are generally recommended as they have been updated.\n\n### Supported data types\nThere are many different ways to store and work with relational data in R. \n`ggraph` is built upon `tidygraph` and the large swath of data structures it \nsupports are thus natively supported in `ggraph`. In order to get a data type \nsupported by `ggraph`, simply provide an `as_tbl_graph` method for it.\n\n## Installation\n`ggraph` is available through CRAN and can be installed with \n`install.packages('ggraph')`. The package is under active development though and\nthe latest set of features can be obtained by installing from this repository\nusing `devtools`\n\n```{r, eval=FALSE}\n# install.packages(\"pak\")\npak::pak('thomasp85/ggraph')\n```\n\n## Related work\n`ggraph` is not the only package to provide some sort of support for relational\ndata in `ggplot2`, though I'm fairly certain that it is the most ambitious.\n[`ggdendro`](https://CRAN.R-project.org/package=ggdendro) provides support for \n`dendrogram` and `hclust` objects through conversion of the structures into\nline segments that can then be plotted with `geom_segment()`. \n[`ggtree`](https://bioconductor.org/packages/ggtree/) provides more extensive\nsupport for all things tree-related, though it lacks some of the layouts and \nedge types that `ggraph` offers (it has other features that `ggraph` lacks \nthough). For more standard *hairball* network plots \n[`ggnetwork`](https://CRAN.R-project.org/package=ggnetwork), \n[`geomnet`](https://CRAN.R-project.org/package=geomnet), and \n[`GGally`](https://CRAN.R-project.org/package=GGally) all provide some \nfunctionality though none of them are as extensive in scope as `ggraph`.\n\n## Code of Conduct\nPlease note that the 'ggraph' project is released with a\n[Contributor Code of Conduct](https://ggraph.data-imaginist.com/CODE_OF_CONDUCT.html).\nBy contributing to this project, you agree to abide by its terms.\n","funding_links":[],"categories":["R","Network Visualization"],"sub_categories":["Miscellaneous"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasp85%2Fggraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasp85%2Fggraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasp85%2Fggraph/lists"}