ggraph

Ggraph node color to match edge color

一曲冷凌霜 提交于 2019-12-25 04:08:12
问题 Is it possible to get ggraph to plot node colors the same color as connected edge color? I've tried feeding ggraph the colors for edges and nodes manually without any luck. It seems as if this would be something rather trivial, but I can't find any direction on it. My question is somewhat similar to this question, but I would like to color my nodes the same as their out-degree edges. library(tidyverse) library(igraph) library(ggraph) g <- graph_from_data_frame(highschool) ggraph(g)+ geom_edge

R : how to control behaviour of edges in ggraph

爱⌒轻易说出口 提交于 2019-12-24 03:54:11
问题 I'm facing this issue: I got some data like these: library(tidyverse) library(tidygraph) library(ggraph) library(ggrepel) edges <- data.frame(a=c('k','k','k','k','k','z','z'), b=c('b','b','b','b','c','b','c'), costant = 1) a b costant 1 k b 1 2 k b 1 3 k b 1 4 k b 1 5 k c 1 6 z b 1 7 z c 1 Now I would lik to have a graph with ggraph that have nodes and edges with weights. So I worked this way: # first I calculated the edges weights edges1 <- edges%>% group_by(a,b) %>% summarise(weight = sum

Manual legend in ggraph/ggplot2 [R]

廉价感情. 提交于 2019-12-13 16:55:20
问题 Apart from this post, here I am asking new questions how to make adjustment in legends built by ggraph . Here are scripts to produce current plot: ## Packages library(igraph) library(tidygraph) library(ggraph) library(ggplot2) library(tidyverse) ## Edge and node edge <- data.frame(from=c(0,0,0,0,1,2,3), to=c(0,1,2,3,0,0,0), weight=c(1,3,1,1,3,1,1)) node <- data.frame(id=c(0,1,2,3), p=c(9,1,0,0), w=c(0,2,0,0), s=c(0,1,1,1), size=c(9,3,1,1), gr=c(0,1,1,2)) ## Load data frames as tbl_graph class

How to draw graph corresponding with its attributes in ggraph [R]

↘锁芯ラ 提交于 2019-12-11 08:38:16
问题 I am trying to draw following graph in ggraph . igraph class object is obtained from a data frame below: edge <- data.frame(from=c(0,0,0,0,1,2,3), to=c(0,1,2,3,0,0,0), weight=c(1,3,1,1,3,1,1)) node <- data.frame(id=c(0,1,2,3), p=c(9,1,0,0), w=c(0,2,0,0), s=c(0,0,1,1), size=c(9,3,1,1), gr=c(0,1,1,2)) # Convert data frame into igraph class object net <- graph_from_data_frame(d=edge,vertices=node,directed=TRUE) However, when I draw the graph in the following scripts, it produces unexpected width

Choose color ggraph R

依然范特西╮ 提交于 2019-12-11 07:59:52
问题 I try to plot a bipartite network with the edges of the same color than one of their nodes. For example, let's take an movie/actor bipartite graph as an exemple, with 7 movies and 15 actors, and each actor has a nationality. I want to have the edge between an actor and a movie of the same color than the nationality of the actor. NG1 <- 7 NG2 <- 15 Nat <- sample(x = c("French", "English", "Italian", "American", "Chinese"), size = NG2, replace = T) G <- graph.empty(NG1+NG2) [Here, head(Nat)

how to use circle pack layout in ggraph library in r

社会主义新天地 提交于 2019-12-11 06:26:48
问题 what data format is necessary to create ggraph circlepack layout? It seems to require a hierarchy. I tried normally vertices and nodes, which apparently doesn't work. library(ggraph) library(igraph) edges=data.frame(from=c('a','b','c'), to= c('c','a','d')) vertices=data.frame(nodes=c('a','b','c','d'), weight=c(1,2,3,4)) graph <- graph_from_data_frame(edges, vertices = vertices) ggraph(graph, 'circlepack', weight = 'size') + geom_node_circle(size = 0.25, n = 50) + coord_fixed() I then tried a

How to install GGRAPH package to the latest R (v.3.3.2)

痞子三分冷 提交于 2019-12-10 20:26:14
问题 I am very new to R and I need ggraph library and it can't be installed from rstudio console. Here is a message: Warning in install.packages : package ‘ggraph’ is not available (for R version 3.3.2) Are there other ways of installation? Looks like this library lives and flourishes: https://www.r-bloggers.com/introduction-to-ggraph-layouts/ 回答1: This requires udunits2 library. I use conda R, so I installed it using conda install -c ioos udunits2=2.2.20 . You need to use a package manager to get