Empty plots in mixed subplot (R)

My goal is to create a subplot with a contour map and x and y marginal barplots. The example I am working from is the last example here: https://plot.ly/r/contour-plots/

Of course, the example is a contour plot so that may cause part of the issue. However, I find that none of my plots are showing up at all when I run this code:

subplot(
plot_ly(x = xz[,2], y = xz[,1], type = ‘bar’),
plotly_empty(type = “scatter”, mode = “markers”),
plot_ly(x = X1, y = Y1, z = intensity, type = “heatmapgl”),
plot_ly(x = yz[,1], y = yz[,2], type = ‘bar’, orientation = ‘h’),
nrows = 2, heights = c(0.2, 0.8), widths = c(0.8, 0.2), margin = 0,
shareX = TRUE, shareY = TRUE, titleX = FALSE, titleY = FALSE
)

All of the plots when run on their own show up nicely. However, when all set within the subplot function, only bar plots would show up. I tried updating plotly and the result was that now the bar plots don’t even show up. Is it possible to do this at all with a heatmap?

@rml219, I wonder if the problem is that the axes don’t match properly. In you’re case xz[,2] will need to equal X1and Y1 must equal yz[,2] and maybe they don’t? That would explain why one doesn’t show up after putting them all together.

Here is an example showing a heatmap with marginal subplots in plotly which I ran using version 4.9 of plotly.R

x_var <- runif(10)
y_var <- runif(10)

x_axis <- seq(10)
y_axis <- seq(10)
s <- subplot(
  plot_ly(x = x_axis, y = y_var, type = "bar"),
  plotly_empty(),
  plot_ly(x = x_axis, y = y_axis, z = outer(x_var,y_var), type = "heatmap"),
  plot_ly(x = x_var, y = y_axis, type = "bar", orientation ='h'),
  nrows = 2, heights = c(0.2, 0.8), widths = c(0.8, 0.2), margin = 0,
  shareX = TRUE, shareY = TRUE, titleX = FALSE, titleY = FALSE
)
p <- layout(s, showlegend = FALSE, bargap=0)
p