Tight update 4.5.2 violated my rectangular heatmap

I updated the planning package and now I have problems with my heatmap.

m <- matrix(rnorm(8), nrow = 4, ncol = 2)
plot_ly(
  x = c("a", "b"), y = c("c", "d", "e", "f"),
  z = m, type = "heatmap"
)

gives me an error:

Error: Variables must be length 1 or 4.
Problem variables: 'x'

Any idea on how to fix it? Adding blank tags did not help. The only solution that actually worked was to repeat the vector

x = c("a", "b", "a", "b")

or

x = c("a", "b", "b", "b")

However, I would like to have a more accurate solution, since with a large data set it can become messy.

+4
source share
2 answers

I think this is a mistake, but by specifying as many variables as max(dim(m))your code fixes.

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")

enter image description here

+3
source

IF you upgrade to 4.5.5.9000, this error has already been resolved.

devtools::install_github("ropensci/plotly")
+1
source

Source: https://habr.com/ru/post/1657993/


All Articles