轴上的R IGRAPHE格式日期
在下面的igraph中,有一些日期要绘制为x轴上的标记。下面我提供了一个例子。当日期在标签矩阵中指定时,它们被格式化为原子值。如何使x轴上的日期以常规日期格式显示轴上的R IGRAPHE格式日期,r,date,matrix,plot,igraph,R,Date,Matrix,Plot,Igraph,在下面的igraph中,有一些日期要绘制为x轴上的标记。下面我提供了一个例子。当日期在标签矩阵中指定时,它们被格式化为原子值。如何使x轴上的日期以常规日期格式显示 library(igraph) nodes=data.frame( c(0,1,2,3), c("A","B","C","D") ) colnames(nodes) = c("id","name") links = data.frame( c(0,0,1,2), c(1,2,3,3) ) colnames(li
library(igraph)
nodes=data.frame(
c(0,1,2,3),
c("A","B","C","D")
)
colnames(nodes) = c("id","name")
links = data.frame(
c(0,0,1,2),
c(1,2,3,3)
)
colnames(links) = c("from","to")
layout = matrix(
c(as.Date('2010-01-01'),1, as.Date('2010-01-02'),1, as.Date('2010-01-02'),2, as.Date('2010-01-06'),1), byrow = TRUE, nrow=4
)
net = graph.data.frame(links, vertices = nodes)
plot.igraph(
net, xaxt="n",layout=layout,axes=TRUE,asp=0, rescale=FALSE,xlim=c(as.Date('2010-01-01'),as.Date('2010-01-06')),ylim=c(1,2)
)
如前所述,可以使用自己的值替换轴。 使用您的代码,它提供:
layout <- data.frame(Date = as.Date(c('2010-01-01','2010-01-02','2010-01-02','2010-01-06')), value = c(1,2,1,1))
plot.igraph(
net,
layout = layout,
rescale = FALSE,
axis = FALSE,
asp = 0,
xlim = as.Date(c('2010-01-01', '2010-01-06')),
ylim = c(1,2)
)
axis(1, at = as.numeric(layout$Date), labels = layout$Date, cex.axis = 0.9)
axis(2, at = 1:max(layout$value), labels = 1:max(layout$value))
layout轴说明的链接指向的是绘图,而不是文章。