简体   繁体   English

轮廓 plot 与使用 plotly 的标记

[英]contour plot with markers using plotly

I would like to generate contour plot (2d) and add point(marks, dots, ... whatever to be visible at specific coordinates(x,y)) on top of the contour plot.我想生成轮廓 plot (2d) 并在轮廓 plot 顶部添加点(标记,点,......在特定坐标(x,y)处可见的任何内容)。

For now I have found the option in plot.ly:现在我在 plot.ly 中找到了这个选项:

df <- data.frame(xv=rnorm(10),yv=rnorm(10),zv=rnorm(10))
p <- plot_ly(data = df, x=~xv,y=~yv, z=~zv, type = "contour") 

so that I can generate colorful interpretation of 3d(xyz) on 2d(xy) view.这样我就可以在 2d(xy) 视图上生成 3d(xyz) 的彩色解释。 But I have no idea how to add any marks/signs/dots on top of it?但我不知道如何在上面添加任何标记/标志/点?

You can use add_trace() like this:您可以像这样使用add_trace()

plot_ly(data = df, x=~xv,y=~yv, z=~zv, type = "contour") %>%
  add_trace(x=~xv,y=~yv, size=~zv, type = "scatter")

Here I've mapped zv to the size attribute of the marker but this is optional of course.在这里,我将zv映射到标记的size属性,但这当然是可选的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM