如何使用 plot_ly 在 R 中的轮廓线上赋值

How can I assign value on contour line in R using plot_ly

我在 R Studio 中使用 plot_ly 绘制等高线图。我希望等高线直接在图表上显示它们的值(类似于此处的图像:http://www.cyber-wit.com/onlineHelp/Images/contour.png)。我不知道如何实现这一目标。 这是我的代码:

plot_ly(width = 600, height = 600,
      type = 'contour',
      z=Matrix_Contour,
)

感谢您的帮助!

为此你需要 showlabels = TRUE:

plot_ly(z = volcano, type = "contour", contours = list(showlabels = TRUE))