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
4
votes
1 answer

How to draw an arrowhead in the middle of an edge in ggraph

Is it possible to draw an arrowhead in the middle of an edge using ggraph::geom_edge_link(), and if so how can this be done? Rather than something like this with the arrowheads drawn at the ends of the…
Mark_1
  • 331
  • 1
  • 3
  • 16
4
votes
1 answer

How to adjust the width of edges by weight in ggraph network in r

I need to generate a network with ggraph in r. What I want is adjust the edge width by weight variable (or the size of nodes). Does anyone know how I can do that? Thanks a lot. Example code…
zesla
  • 11,155
  • 16
  • 82
  • 147
4
votes
0 answers

Make edges point to repelled labels in ggraph

I am creating a graph using the ggraph R package. I want to label all the nodes using geom_node_label(), but this often create overlaps. One way to fix is this is to use the repel=TRUE argument. Unfortunately I cant seem to figure out how to also…
user1593755
  • 141
  • 2
4
votes
1 answer

Positioning nodes and edges in network graph using ggraph/ggplot2

I'm trying to plot a network with ggraph and I'd like to add a circle around the graph, with the edges and nodes lying centered inside the circle. Drawing the circle works just fine with the following code (adapted from Draw a circle with…
lisah
  • 186
  • 1
  • 9
4
votes
2 answers

Plot labels for specific geom_node_text

I am trying to plot a network graph and show only the labels for the geom_node_text that have a centrality score above a specific threshold. My code is below: rt_tbl %>% mutate(centrality = centrality_authority()) %>% ggraph(layout = 'kk') +…
mundos
  • 459
  • 6
  • 14
4
votes
2 answers

Nodes not respecting facetting in ggraph/igraph

I am having a little trouble understanding the difference between ggplot2 and ggraph with respect to facetting. Consider the following data: library(igraph) library(ggraph) library(ggplot2) df <- structure(list(x = c("H001", "H024", "H090",…
boshek
  • 4,100
  • 1
  • 31
  • 55
4
votes
2 answers

Controlling facet order in ggraph

I want to plot a graph using facets, where the edges vary between panels. The panels are automatically ordered alphabetically (as is customary in ggplot). A simple example: library(igraph) library(ggraph) g <- make_empty_graph() + vertices(1:2)…
Axeman
  • 32,068
  • 8
  • 81
  • 94
4
votes
1 answer

How to read a text label in ggraph radial graph

In ggraph, if the plot is radial, the labels can get crowded, whether using repel=T or not. Is there a way to make label interactive or allowing rotating the graph in order to read the labels? library(ggraph) mtcarsDen <-…
santoku
  • 3,297
  • 7
  • 48
  • 76
3
votes
1 answer

R automated procedure for placement of loops in network graphs

I aim to draw a circular network that contains loops, i.e., the beginning and the end of the edge are at the same node. If there are many connections between nodes, the problem arises that loops are always drawn on the right side. This leads to a…
carl
  • 305
  • 2
  • 13
3
votes
1 answer

Different aesthetic scales for different types of edges on same graph

I am trying to visualize some networks using the ggraph package. My network has two different types of edges, A and B, which have different scales. I'd like to color the edges by type (which I've done) and also modulate their opacity by the value.…
3
votes
1 answer

How do I mark the center node in a tidygraph

Using this reproducable example from another question. How do I label / colour the center node on which the local neighborhood graph is based. (In this case 'x') library(tidygraph) library(ggraph) # Example net <- tibble::tibble(A = letters[1:6], …
Nina van Bruggen
  • 393
  • 2
  • 13
3
votes
1 answer

Control order of nodes in ggraph tree

Is it possible to control the horizontal order of nodes in a ggraph tree? The following code creates a tree: library(ggraph) library(igraph) library(tidyverse) mygraph <- tibble(from = c("A", "A", "C", "C"), to = c( "B", "C", "D", "E")) %>% …
Ryan
  • 33
  • 3
3
votes
1 answer

plot ggraph using supplied node coordinates

As the title says. I have a graph object created using igraph::sample_grg(), which I want to plot using ggraph, with nodes positioned according to the node attributes x and y. What I have tried: Create…
flee
  • 1,253
  • 3
  • 17
  • 34
3
votes
1 answer

Can an igraph object have directed and undirected edges?

I am trying to use igraph/ggraph to plot a network, in which some of the edges are directed and others are not. A small example from my edgelist. Here the protein-site edges are what I want to represent as undirected and the phosphorylation edge as…
Jatson
  • 43
  • 6
3
votes
0 answers

Changing the shape used in legend in ggraph

I'm trying to change the shape used in the legend from a square to circle with a fill aesthetic, but none of the override arguments seem to be working. If: library(ggraph) library(igraph) g <- graph_from_data_frame(highschool) ggraph(g) + …
T.P.
  • 87
  • 1
  • 6
1
2
3
13 14