我希望能够制作一个R图热图,除了显示关于z的信息外,我还将有更多的信息,这些信息将是文本信息。
我的意思是:我有这个数据集数据集:
library(plotly)
m <- matrix(c(NA, 1,3, 2, NA, 4, 3, 0, NA), nrow = 3, ncol = 3)
fig <- plot_ly(
x = c("Epilepsy", "PTSD", "Depression"), y = c("Dizziness", "Slowed Thinking/ Decision-making
", "Hearing/Noise Sensitivity
"),
z = m, type = "heatmap"
)这给了我以下输出:

然而,我需要更多的东西,当我点击每个部分时,我也有这个变量:
p <- matrix(c(NA, "XX","YY", "TT", NA, "ST", "PO", "IU", NA), nrow = 3, ncol = 3)正如您所看到的,这不是数字,它只是提供了有关关联的更多信息。
发布于 2020-12-15 05:38:51
您可以将矩阵p添加到text属性中,即
fig <- plot_ly(
x = x,
y = y,
z = m,
type = "heatmap",
text = p
)完整代码
library(plotly)
m <- matrix(c(NA, 1,3, 2, NA, 4, 3, 0, NA), nrow = 3, ncol = 3)
p <- matrix(c(NA, "XX","YY", "TT", NA, "ST", "PO", "IU", NA), nrow = 3, ncol = 3)
fig <- plot_ly(
x = x,
y = y,
z = m,
type = "heatmap",
text = p
)
fig

https://stackoverflow.com/questions/65296580
复制相似问题