Plotly 4.5.2 更新破坏了我的矩形热图
Plotly 4.5.2 update broke my rectangular heatmap
我更新了 plotly 包,现在我的热图有问题。
m <- matrix(rnorm(8), nrow = 4, ncol = 2)
plot_ly(
x = c("a", "b"), y = c("c", "d", "e", "f"),
z = m, type = "heatmap"
)
给我一个错误:
Error: Variables must be length 1 or 4.
Problem variables: 'x'
知道如何解决吗?添加空标签没有帮助。唯一有效的解决方案是重复 vector
x = c("a", "b", "a", "b")
或
x = c("a", "b", "b", "b")
但是我想要一个更简洁的解决方案,因为如果数据集更大,它可能会变得混乱。
我认为这是一个错误,但指定与 max(dim(m))
一样多的变量将修复您的代码。
set.seed(123)
m <- matrix(rnorm(8), nrow = 4, ncol = 2)
dim(m)
plot_ly(
x = c(letters[1:2], "NA", "NA"), y = letters[3:6],
z = m, type = "heatmap")
如果您更新到 4.5.5.9000,此错误已解决。
devtools::install_github("ropensci/plotly")
我更新了 plotly 包,现在我的热图有问题。
m <- matrix(rnorm(8), nrow = 4, ncol = 2)
plot_ly(
x = c("a", "b"), y = c("c", "d", "e", "f"),
z = m, type = "heatmap"
)
给我一个错误:
Error: Variables must be length 1 or 4.
Problem variables: 'x'
知道如何解决吗?添加空标签没有帮助。唯一有效的解决方案是重复 vector
x = c("a", "b", "a", "b")
或
x = c("a", "b", "b", "b")
但是我想要一个更简洁的解决方案,因为如果数据集更大,它可能会变得混乱。
我认为这是一个错误,但指定与 max(dim(m))
一样多的变量将修复您的代码。
set.seed(123)
m <- matrix(rnorm(8), nrow = 4, ncol = 2)
dim(m)
plot_ly(
x = c(letters[1:2], "NA", "NA"), y = letters[3:6],
z = m, type = "heatmap")
如果您更新到 4.5.5.9000,此错误已解决。
devtools::install_github("ropensci/plotly")