3d contour plot in R I have 2 vectors $1000 \times 1$, lets call them $y_{1}$ and $y_{2}$. Each vector represents a normal distribution with certain mean and variance.

I plot the contour plot using the following R code:

x &lt;- y1
y &lt;- y2
s &lt;- subplot(
  plot_ly(x = x, type = "histogram", showlegend=FALSE),
  plotly_empty(),
  plot_ly(x = x, y = y, type = "histogram2dcontour", showlegend=FALSE),
  plot_ly(y = y, type = "histogram", showlegend=FALSE),
  nrows = 2, heights = c(0.2, 0.8), widths = c(0.8, 0.2),
  shareX = TRUE, shareY = TRUE, titleX = FALSE, titleY = FALSE
)
layout(s)


and i get the following plot



What I would like to do now, is to plot a 3D contour plot (so that I can actually see the "mountain" that is created after plotting the histogram of $y_{1}$ against the histogram of $y_{2}$). So in the z-axis I would like to have the frequencies of the values. Any suggestions ?
This plot not use frequencies but kernel density:

freqz &lt;- with(data.frame(x,y), MASS::kde2d(x, y, n = 50))
with(freqz, plot_ly(x = x, y = y, z = z, type = "surface"))