单列的 3D 带状图
3D Ribbon plot for a single column
我能够为矩阵创建 ribbon3D 图,该矩阵的行和列维度都大于 1。当其中一个维度为 1 时,我遇到了一个问题。这意味着如果我有 12 行和一列,那么我的代码会出错。
需要帮助解决这种情况。
给出一个table的样本数据如下:
structure(c(3, 4, 2, 2, 9, 6, 6, 7, 8, 10, 11), .Dim = c(1L,
11L), .Dimnames = list("Fruits and nuts (excluding oil nuts), fresh or dried",
c("2005", "2006", "2007", "2008", "2009", "2010", "2011",
"2012", "2013", "2014", "2015")))
绘图使用的代码如下:
library(plot3D)
ribbon3D(x = 1:nrow(rs12), y = 1:ncol(rs12), z = rs12, scale = T, expand = .2, bty = "b", along = "y",
colvar = rs12, colkey = F, border = "black", shade = 0.1,
theta = -50, phi = 40, space = .5, d = 2,
curtain = T, xlab = "", ylab = "", zlab = "", main = "Pakistan's Exports to Russia",
cex.axis = 0.000000000001, box = F)
对于那些对它如何处理大于 1 的矩阵感兴趣的人。这里是示例数据。但是在代码中将矩阵名称从 rs12
更改为 tf12
。
运行 上述代码在上面示例中的错误是这样的,Error in persp.default(plist$xlim, plist$ylim, z = matrix(nrow = 2, ncol = 2, : increasing 'x' and 'y' values expected
.
dput(tf12)
structure(c(18, 36, 18, 39, 41, 18, 18, 18, 18, 36, 37, 18, 38,
18, 18, 18, 40, 18, 18, 17, 36, 17, 39, 41, 17, 17, 17, 34, 38,
36, 17, 34, 17, 17, 17, 40, 17, 17, 16, 38, 34, 40, 41, 16, 16,
16, 16, 36, 36, 16, 34, 34, 34, 16, 39, 16, 16, 32, 40, 32, 40,
41, 32, 32, 32, 14, 36, 36, 14, 14, 32, 32, 14, 38, 14, 14, 16,
38, 33, 39, 41, 33, 16, 33, 33, 37, 36, 16, 33, 16, 16, 16, 40,
16, 16, 14, 39, 31, 40, 41, 31, 31, 31, 31, 37, 36, 31, 14, 31,
14, 31, 38, 14, 31, 30, 37, 30, 39, 41, 36, 13, 30, 30, 38, 30,
30, 30, 30, 30, 30, 40, 13, 13, 15, 38, 32, 39, 41, 32, 15, 15,
32, 38, 32, 32, 15, 32, 36, 15, 40, 15, 15, 15, 38, 32, 39, 41,
36, 15, 15, 32, 38, 32, 32, 15, 15, 32, 15, 40, 32, 15, 15, 38,
32, 39, 41, 36, 15, 15, 32, 32, 32, 36, 15, 32, 36, 15, 40, 15,
15, 16, 38, 34, 39, 41, 37, 16, 16, 34, 16, 34, 16, 16, 34, 34,
16, 40, 16, 16), .Dim = c(19L, 11L), .Dimnames = list(c("Pig iron & spiegeleisen, sponge iron, powder & granu",
"Ores and concentrates of base metals, n.e.s.", "Waste, parings and scrap, of plastics",
"Leather", "Textile yarn", "Stone, sand and gravel", "Fish, dried, salted or in brine; smoked fish",
"Copper", "Non-ferrous base metal waste and scrap, n.e.s.", "Cotton",
"Fish, fresh (live or dead), chilled or frozen", "Feeding stuff for animals (no unmilled cereals)",
"Carboxylic acids, anhydrides, halides, per.; derivati.", "Crustaceans, mollusks and aquatic invertebrates",
"Crude vegetable materials, n.e.s.", "Polymers of ethylene, in primary forms",
"Cotton fabrics, woven", "Other crude minerals", "Ships, boats & floating structures"
), c("2005", "2006", "2007", "2008", "2009", "2010", "2011",
"2012", "2013", "2014", "2015")))
这是由 ribbon3D
中的错误引起的:它对矩阵进行子集化,但没有告诉 R 将其保留为矩阵,因此它变成了向量,之后事情变得很糟糕。
您可以使用 fix()
功能自行修复该错误,对其进行编辑并创建本地副本,但您最终会遇到不同的错误,很可能是由其他地方的相同问题引起的。
我建议你有两个选择:
花一些时间追踪并解决所有这些问题。这是学习 R 调试的好机会,但需要一段时间。将它们全部修复后,将必要更改列表发送给 plot3D
包的维护者。
写信给维护者,包括你的可重现的例子,希望她有兴趣和时间来解决这个问题。
我能够为矩阵创建 ribbon3D 图,该矩阵的行和列维度都大于 1。当其中一个维度为 1 时,我遇到了一个问题。这意味着如果我有 12 行和一列,那么我的代码会出错。 需要帮助解决这种情况。
给出一个table的样本数据如下:
structure(c(3, 4, 2, 2, 9, 6, 6, 7, 8, 10, 11), .Dim = c(1L,
11L), .Dimnames = list("Fruits and nuts (excluding oil nuts), fresh or dried",
c("2005", "2006", "2007", "2008", "2009", "2010", "2011",
"2012", "2013", "2014", "2015")))
绘图使用的代码如下:
library(plot3D)
ribbon3D(x = 1:nrow(rs12), y = 1:ncol(rs12), z = rs12, scale = T, expand = .2, bty = "b", along = "y",
colvar = rs12, colkey = F, border = "black", shade = 0.1,
theta = -50, phi = 40, space = .5, d = 2,
curtain = T, xlab = "", ylab = "", zlab = "", main = "Pakistan's Exports to Russia",
cex.axis = 0.000000000001, box = F)
对于那些对它如何处理大于 1 的矩阵感兴趣的人。这里是示例数据。但是在代码中将矩阵名称从 rs12
更改为 tf12
。
运行 上述代码在上面示例中的错误是这样的,Error in persp.default(plist$xlim, plist$ylim, z = matrix(nrow = 2, ncol = 2, : increasing 'x' and 'y' values expected
.
dput(tf12)
structure(c(18, 36, 18, 39, 41, 18, 18, 18, 18, 36, 37, 18, 38,
18, 18, 18, 40, 18, 18, 17, 36, 17, 39, 41, 17, 17, 17, 34, 38,
36, 17, 34, 17, 17, 17, 40, 17, 17, 16, 38, 34, 40, 41, 16, 16,
16, 16, 36, 36, 16, 34, 34, 34, 16, 39, 16, 16, 32, 40, 32, 40,
41, 32, 32, 32, 14, 36, 36, 14, 14, 32, 32, 14, 38, 14, 14, 16,
38, 33, 39, 41, 33, 16, 33, 33, 37, 36, 16, 33, 16, 16, 16, 40,
16, 16, 14, 39, 31, 40, 41, 31, 31, 31, 31, 37, 36, 31, 14, 31,
14, 31, 38, 14, 31, 30, 37, 30, 39, 41, 36, 13, 30, 30, 38, 30,
30, 30, 30, 30, 30, 40, 13, 13, 15, 38, 32, 39, 41, 32, 15, 15,
32, 38, 32, 32, 15, 32, 36, 15, 40, 15, 15, 15, 38, 32, 39, 41,
36, 15, 15, 32, 38, 32, 32, 15, 15, 32, 15, 40, 32, 15, 15, 38,
32, 39, 41, 36, 15, 15, 32, 32, 32, 36, 15, 32, 36, 15, 40, 15,
15, 16, 38, 34, 39, 41, 37, 16, 16, 34, 16, 34, 16, 16, 34, 34,
16, 40, 16, 16), .Dim = c(19L, 11L), .Dimnames = list(c("Pig iron & spiegeleisen, sponge iron, powder & granu",
"Ores and concentrates of base metals, n.e.s.", "Waste, parings and scrap, of plastics",
"Leather", "Textile yarn", "Stone, sand and gravel", "Fish, dried, salted or in brine; smoked fish",
"Copper", "Non-ferrous base metal waste and scrap, n.e.s.", "Cotton",
"Fish, fresh (live or dead), chilled or frozen", "Feeding stuff for animals (no unmilled cereals)",
"Carboxylic acids, anhydrides, halides, per.; derivati.", "Crustaceans, mollusks and aquatic invertebrates",
"Crude vegetable materials, n.e.s.", "Polymers of ethylene, in primary forms",
"Cotton fabrics, woven", "Other crude minerals", "Ships, boats & floating structures"
), c("2005", "2006", "2007", "2008", "2009", "2010", "2011",
"2012", "2013", "2014", "2015")))
这是由 ribbon3D
中的错误引起的:它对矩阵进行子集化,但没有告诉 R 将其保留为矩阵,因此它变成了向量,之后事情变得很糟糕。
您可以使用 fix()
功能自行修复该错误,对其进行编辑并创建本地副本,但您最终会遇到不同的错误,很可能是由其他地方的相同问题引起的。
我建议你有两个选择:
花一些时间追踪并解决所有这些问题。这是学习 R 调试的好机会,但需要一段时间。将它们全部修复后,将必要更改列表发送给
plot3D
包的维护者。写信给维护者,包括你的可重现的例子,希望她有兴趣和时间来解决这个问题。