r - 使用 Plotly 在等高线图上叠加线
问题描述
我想在 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)
呈现:
使用 Plotly,我尝试过
library(plotly)
plot_ly(x = 1:6, y = 1:6, z = t(m), type = "contour") %>%
add_lines(x = path$x, y = path$y)
这会生成一个等高线图,上面覆盖着空白线框R3
而不是一条线:
解决方案
推荐阅读
- regex - 查找所有以给定短语开头和结尾的地方,并在 VS Code 中每个出现的开头添加一个特殊符号
- python - 在 ABC 的不同具体实现之间选择实例化对象
- python - python抓取json比较文件
- java - 为什么 Spring Boot 从 spring-rabbit 中排除 http-client?
- php - Wordpress:根据 url 更改主菜单
- apache-storm - 我可以动态增加运行 Storm 拓扑的并行度吗
- r - 如何根据类估算数据
- api - 指定的供应商编号无效。再试一次。- 应用商店连接 API
- javascript - JS RegEx在一行中查找并替换所有html链接
- c# - 我的使用 Slack 的 BotFramework 机器人如何忽略除直接以外的所有渠道上的消息?