gpt4 book ai didi

rigraph 绘图布局错误 : incorrect number of subscripts on matrix

转载 作者:行者123 更新时间:2023-12-05 08:09:25 25 4
gpt4 key购买 nike

我正在尝试手动设置 igraph 图的顶点坐标。坐标表示纬度和经度值。我不断收到错误消息:

Error in ec[, 3:4] <- t(sapply(seq(length = nrow(el)), function(x) { : 
incorrect number of subscripts on matrix

这是我正在使用的对象/变量:

图形对象-

    > g_mat_cut
IGRAPH UNW- 28 88 --
+ attr: name (v/c), shape (v/c), color (v/c), weight (e/n)
+ edges (vertex names):
[1] 010C10AB53--010C10CA44 010C10AB53--010C10D28B 010C10AB53--010C10D28E
[4] 010C10AB53--010C10EA1E 010C10AB53--010C1108EB 010C10AB53--010C11169A
[7] 010C10AB53--010C112145 010C10AB53--010C117822 010C10AB53--010C117E53
[10] 010C10AB53--010C1180A0 010C10AB53--010C11922B 010C10AB53--010C11B911
[13] 010C10AB53--010C11BBA6 010C10AB53--010C11BC8D 010C10AB53--010C11BEB7
[16] 010C10C3A5--010C116DC1 010C10CA44--010C10D28B 010C10CA44--010C114E81
[19] 010C10CA44--010C11B911 010C10CA44--010C11BBA6 010C10CBBD--010C117822
[22] 010C10D28B--010C10D28E 010C10D28B--010C1108EB 010C10D28B--010C11169A
+ ... omitted several edges

具有以下顶点属性 -

 vertex.attributes(g_mat_cut)
$name
[1] "010C10AB53" "010C10BEA5" "010C10C3A5" "010C10CA44" "010C10CBBD"
[6] "010C10D28B" "010C10D28E" "010C10EA1E" "010C10EFE8" "010C11059F"
[11] "010C1108EB" "010C1111B5" "010C111428" "010C11169A" "010C112145"
[16] "010C114E81" "010C115391" "010C116DC1" "010C117822" "010C117E53"
[21] "010C1180A0" "010C11922B" "010C119C7E" "010C11A61D" "010C11B911"
[26] "010C11BBA6" "010C11BC8D" "010C11BEB7"

$shape
[1] "circle" "square" "square" "square" "square" "square" "square" "square"
[9] "circle" "square" "square" "square" "square" "square" "square" "circle"
[17] "circle" "circle" "circle" "circle" "square" "square" "square" "square"
[25] "square" "circle" "square" "circle"

$color
[1] "#99D594" "#3288BD" "#3288BD" "#3288BD" "#99D594" "#99D594" "#3288BD"
[8] "#3288BD" "#D53E4F" "#D53E4F" "#99D594" "#3288BD" "#3288BD" "#3288BD"
[15] "#3288BD" "#3288BD" "#D53E4F" "#D53E4F" "#3288BD" "#3288BD" "#3288BD"
[22] "#99D594" "#3288BD" "#99D594" "#3288BD" "#3288BD" "#FEE08B" "#FEE08B"

顶点位置的空间坐标:

 coords
[,1] [,2]
[1,] 50.19954 -5.169506
[2,] 50.19866 -5.168653
[3,] 50.19853 -5.169905
[4,] 50.19856 -5.168397
[5,] 50.19954 -5.169506
[6,] 50.19794 -5.168535
[7,] 50.19833 -5.169241
[8,] 50.19897 -5.169436
[9,] 50.19915 -5.169564
[10,] 50.19908 -5.169429
[11,] 50.19878 -5.169403
[12,] 50.19857 -5.170018
[13,] 50.19859 -5.168570
[14,] 50.19847 -5.169863
[15,] 50.19982 -5.171222
[16,] 50.19866 -5.168653
[17,] 50.19844 -5.168694
[18,] 50.19794 -5.168535
[19,] 50.19833 -5.169241
[20,] 50.19781 -5.168733
[21,] 50.19855 -5.168908
[22,] 50.19915 -5.169564
[23,] 50.20034 -5.170551
[24,] 50.19878 -5.169697
[25,] 50.19882 -5.170664
[26,] 50.19982 -5.171222
[27,] 50.19838 -5.170642
[28,] 50.19841 -5.169932

str(coords)
num [1:28, 1:2] 50.2 50.2 50.2 50.2 50.2 ...

attempt at plotting:

plot(g_mat_cut,layout=coords,vertex.size=4,rescale=FALSE,xlim=c(50.19,50.21),ylim=c(-5.16,-5.18))
Error in ec[, 3:4] <- t(sapply(seq(length = nrow(el)), function(x) { :
incorrect number of subscripts on matrix

最佳答案

我无法真正回答您的问题,但也许我尝试过的方法可以帮助您。

我遇到了同样的问题,因为我尝试使用与某些顶点的圆不同的顶点形状。具有不同的顶点形状并且不指定布局矩阵可以正常工作。并且拥有所有 vertex.shape = "circle" 并指定布局矩阵也可以。设置 vertex.shape = "square" 并尝试使用布局矩阵绘制 - 不可重现 - 行:

plot(gBase, layout=matrix(c(as.numeric(V(gBase)$lon), as.numeric(V(gBase)$lat)), ncol=2), vertex.label= NA, vertex.shape = "正方形", vertex.size = as.numeric(V(gBase)$size), vertex.size2=as.numeric(V(gBase)$size2))

给出这个错误:

y1 - y2 错误:二元运算符的非数字参数

如您所见,我已经尝试将大小和布局强制设置为数字(尽管它们从一开始就设置为数字值)。您还可以将 vertex.shape = "circle" 替换为 vertex.shape = "rectangle",这样 .size2 实际上就有意义了。错误将是相同的。

因此,我假设问题出在定位形状为“方形”或“矩形”的顶点。

documentation只有一个使用形状和定义的布局绘图的示例并没有真正帮助我。

关于rigraph 绘图布局错误 : incorrect number of subscripts on matrix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37752316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com