Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
轴上的R IGRAPHE格式日期_R_Date_Matrix_Plot_Igraph - Fatal编程技术网

轴上的R IGRAPHE格式日期

轴上的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

在下面的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(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轴说明的链接指向的是绘图,而不是文章。