问题描述
elec <- c("Fp1","Fp2","F7","F3","Fz","F4","F8","FC5","FC1","FC2","FC6","C3","Cz","C4","CP5","CP1","CP2","CP6","P7","P3","Pz","P4","P8","POz","Oz","Fp1","Oz")
edgelist <- get.edgelist(net)
# get vertex labels
label <- get.vertex.attribute(net,"name")
# get vertex groups
group <- get.vertex.attribute(net,"group")
# get vertex fill color
fill <- get.vertex.attribute(net,"color")
# get family
family <- get.vertex.attribute(net,"family")
# get vertex degree
degrees <- degree(net)
# data frame with groups,degree,labels and id
nodes <- data.frame(group,degrees,family,label,fill,id=1:vcount(net))
nodes$family <- factor(nodes$family,levels = unique(nodes$family))
nodes$label <- factor(nodes$label,levels = unique(nodes$label))
nodes <- as_tibble(nodes)
# prepare data for edges
edges <- as_tibble(edgelist)
net.tidy <- tbl_graph(nodes = nodes,edges = edges,directed = TRUE,node_key = "label")
ggraph(net.tidy,layout = "linear") +
geom_edge_arc(alpha = 0.5) +
scale_edge_width(range = c(0.2,2)) +
scale_colour_manual(values= vrtxc) +
geom_node_point(aes(size = degrees,color = family)) +
geom_node_text(aes(label = elec),angle = 90,hjust = 1,nudge_y = -0.5,size = 3) +
coord_cartesian(clip = "off") +
theme_graph()+
theme(legend.position = "top")
但是,我想将两组电极分开,在中间,Oz 所在的位置,一点点,看看有什么不同。在节点属性中,我将它们按组 (1,2) 进行区分,我想知道是否可以使用此信息来扩展 x 轴上的两组顶点,左侧一组 25 个电极,另一组一个在轴的右边,在它们中间留一个空格。
我附上一些数据,以防它有用
> nodes
# A tibble: 50 x 6
group degrees family label fill id
<fct> <dbl> <fct> <fct> <fct> <int>
1 1 5 fronp Fp1_1 #3B9AB2 1
2 1 9 fronp Fp2_1 #3B9AB2 2
3 1 6 fron F7_1 #5DAABC 3
4 1 7 fron F3_1 #5DAABC 4
5 1 11 fron Fz_1 #5DAABC 5
6 1 9 fron F4_1 #5DAABC 6
7 1 11 fron F8_1 #5DAABC 7
8 1 8 fronc FC5_1 #88BAAE 8
9 1 6 fronc FC1_1 #88BAAE 9
10 1 4 fronc FC2_1 #88BAAE 10
# … with 40 more rows
解决方法
如果有人感兴趣,我最终在 nodes
数据框中插入了一些虚拟行,结果成功了。