我想覆盖在顶部的线的Plotly等高线图,类似于覆盖在基质的图像上的线,其中所述强度表示位置z内R3:
# Generate an arbitrary matrix
m <- matrix(sin(1:6^2) * 1:6, nrow = 6)
# Define a path
path <- data.frame(x = c(0:7), y = c(0, 1, 2, 2, 3, 3, 4, 6))
image(x = 1:6, y = 1:6, z = m, col = gray.colors(20), xlab = "x", ylab = "y")
lines(path$x, path$y)
Run Code Online (Sandbox Code Playgroud)
其中呈现:
使用 Plotly,我尝试过
library(plotly)
plot_ly(x = 1:6, y = 1:6, z = t(m), type = "contour") %>%
add_lines(x = path$x, y = path$y) …Run Code Online (Sandbox Code Playgroud)