0
votes

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.

For now I have found the option in 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(x-y-z) on 2d(x-y) view. But I have no idea how to add any marks/signs/dots on top of it?

1

1 Answers

0
votes

You can use add_trace() like this:

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.