Questions tagged [ggraph]

ggraph is the "Grammar for Graph Graphics". At the time of writing, it is an actively maintained library for R that builds upon ggplot2 providing support for relational data structures such as networks, graphs and trees. It provides a concept of layouts to aid in the layout of a graph when visualising it.

Additional information, examples, documentation and the source can be obtained from GitHub - ggraph

209 questions
2
votes
1 answer

Putting Labels Inside Nodes in R ggraph package

I am trying to visualize a network using ggraph. My code is as follows: ggraph(x, layout = "fr") + geom_edge_link(aes(width = weight), alpha = 0.50, edge_color = "grey20") + geom_node_point(color = "black", size = 12, show.legend = FALSE, family…
2
votes
1 answer

Placing geom labels outside of circular layout in ggraph/ggplot2

I am trying to generate an interaction network plot with labeled nodes in a circular layout. I have cobbled together a functional script that shows the connections I want with ggraph, but I can't figure out how to position the node labels relative…
Thomas
  • 77
  • 6
2
votes
1 answer

ggraph maintain layout after edge removal

I would like to maintain graph layout (vertex position) after removing edges. An example: library(igraph) library(ggraph) # create sample graph g <- structure(list(from = c(1, 1, 2, 2, 3, 3), to = c(2, 3, 4, 5, 6, 7)), …
flee
  • 1,253
  • 3
  • 17
  • 34
2
votes
2 answers

Weight must be numeric while trying Circle packing on R GGRAPH

i've seen already the topic on the subjet with this issue : library(ggraph) library(igraph) edges <- flare$edges vertices <- flare$vertices mygraph <- graph_from_data_frame(edges, vertices=vertices) ggraph(mygraph, layout = 'circlepack', weight =…
2
votes
1 answer

ggraph arc diagram clips label text

I am using the igraph and ggraph package to plot an arc diagram. I am having trouble with the geom_node_text parameter because, as the length of the text label increases, the graph lower margin will not increase accordingly. So if the label for a…
Rafael
  • 131
  • 6
2
votes
1 answer

Greek letters in ggraph nodes in R Markdown

When I run the R script below in RStudio, the theta is shown correctly. --- title: "test" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(tidygraph) library(ggraph) ``` # Greek letters ```{r…
jeppeb
  • 103
  • 8
2
votes
1 answer

Smooth transitions between different layouts of the same network in ggraph

I would like to animate the same network using different layouts and having a smooth transition between layouts. I'd like to do this inside the gganimate framework. library(igraph) library(ggraph) library(gganimate) set.seed(1) g <-…
Ben Nutzer
  • 1,082
  • 7
  • 15
2
votes
1 answer

ggraph change geom_node_text color based off key words

Reading Tidytext Mining with R --https://www.tidytextmining.com/nasa.html -- I have the following question: By default the node text color is black and I've been able to adjust the color globally but is it possible to have the default color black…
Atwp67
  • 307
  • 5
  • 21
2
votes
0 answers

How to change node shape and colour in ggraph

The first image is a hand drawn image and the second image is the same graph drawn using ggraph. This is the code that generates the graph. library(igraph) library(tidyverse) library(ggraph) V <- read.table(text = "x y 2 1 …
SriniShine
  • 1,089
  • 5
  • 26
  • 46
2
votes
1 answer

data.frame with nested factors into igraph bubble graph

I have a standard data.Frame with some categorical columns and one numeric column. It represents a nested experimental design (but it doesn't really matter), like this: set.seed(1234) data = data.frame(toplevel=c("A","A","A","A", "B", "B", "B"), …
agenis
  • 8,069
  • 5
  • 53
  • 102
2
votes
1 answer

Adding an attribute column to a tidygraph object

I am trying to figure out how to add attribute data to a tidygraph object specifically for plotting purposes. I can't seem to figure out how take a variable which is associated with a variable level, preserve it when I create a tidygraph object for…
boshek
  • 4,100
  • 1
  • 31
  • 55
2
votes
1 answer

Apply color gradient to ggraph's `geom_conn_bundle`

Context I am using ggraph to arrange nodes (leaves of a tree) in a circular dendrogram and then add connections between some of the nodes (using hierarchical bundling using geom_conn_bundle): library(ggraph) library(igraph) # Example data edges <-…
Maximilian C.
  • 967
  • 5
  • 22
2
votes
1 answer

Why should I use ggraph() with set.seed() in R?

I've recently been learning text mining with tidytext. Today, I encountered the following: set.seed(2017) ggraph(bigram_graph, layout="fr") + geom_edge_link() + geom_node_point() + geom_node_text(aes(label=name), vjust=1, hjust=1) I've used the…
No Ru
  • 37
  • 3
2
votes
1 answer

How to flip x and y axes in ggraph R

The first image is a hand drawn (using MS word) image of a graph. The second image is an attempt to generate the same graph using ggraph. Following is the code I used to automatically draw the graph when given the node-edge connections (the code…
SriniShine
  • 1,089
  • 5
  • 26
  • 46
2
votes
1 answer

Problem using ggraph for plotting bigrams co-occurrence, some lines don't show up

I am trying to plot the co-occurrences of bigrams (from Text Mining with R)like this: Or like this: But following exactly the same codes given in the book, my plots are missing much of the lines and colors. Not sure if it is because I have missed…
shavendy
  • 173
  • 1
  • 1
  • 10