简体   繁体   English

在 Igraph 中绘图时仅显示 x 轴(在 R 中)

[英]Display only x-axis when plotting in Igraph (in R)

I'm doing network visualization with igraph in R.我在 R 中使用 igraph 进行网络可视化。 I want to display a chronological order on the x-axis, the values on the y-axis will be set manually in order "even them out" over the plot, ie the numbers on the y-axis contains no information of use for the reader.我想在 x 轴上显示时间顺序,y 轴上的值将手动设置,以便在 plot 上“均匀排列”,即 y 轴上的数字不包含用于读者。 Hence, I want to only display the x-axis, not the y-axis.因此,我只想显示 x 轴,而不是 y 轴。

Here is a demonstration on my current status.这是我当前状态的演示。

library(igraph)

#graph from dataframe
from <- c("One", "Two")
to <- c("Three", "Three")
fromto <- data.frame(from,to)
fromtograph <- graph_from_data_frame(fromto)

#df with coords
year <- c(400,500,600)
coords <- data.frame(as_ids(V(fromtograph)), year)
coords <- coords[order(match(coords$as_ids.V.fromtograph.., as_ids(V(fromtograph)))),]
coords <- as.matrix(data.frame(coords$year,c(300,100,200)))

plot(fromtograph,layout=coords,rescale=F,axes=T, ylim=c(0,400),xlim=c(0,800),asp=0)

The plot results in this . plot 导致.
I want this我想要这个

Best/John最佳/约翰

I would add a filled (white) rectangle over y-axis.我会在 y 轴上添加一个填充的(白色)矩形。

plot(fromtograph,layout=coords,rescale=F,axes=T, ylim=c(0,400),xlim=c(0,800),asp=0)
rect(-100, -10, 0, 450, col = "white", border = "white")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM