I'd like to overlay a line on top a Plotly contour plot, similar to overlaying a line on an image of a matrix in which the intensity represents position in z
within 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)
Which renders:
Using Plotly, I have attempted
library(plotly)
plot_ly(x = 1:6, y = 1:6, z = t(m), type = "contour") %>%
add_lines(x = path$x, y = path$y)
Which generates a contour plot overlaid with a wireframe of empty R3
space rather than a line:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.