Plotly - Shape positions using subplot

Viewed 2848

I am trying to plot multiple subplots with shapes on each plot. From the following code below, if I display one plot I get the following plot: Correct display of one plot

When I position 4 copies of this plot in a subplot I get the following: Incorrect display of 4 subplots. All shapes are drawn in same location

As you can see all of the 4 lines that should be drawn one on each subplot have all been drawn in the original position in the top left subplot. Any ideas how I can fix this?

** EDIT - using "paper"

If I use the "paper" for xref and yref in the declaration of my edge shapes the shapes do not scale properly. Maybe I am using "paper" in the wrong context here? I have attached an image below result of using xyref="paper"

library(plotly)
library(igraph)

tree <- make_tree(127,2)
tree_layout <- layout_as_tree(tree)
tree_layout_df <- as.data.frame(tree_layout)
Xn <- tree_layout_df[,1]
Yn <- tree_layout_df[,2]

edge_shapes  = list(
    type="line",
    line=list(color="#030303",width=5),
    opacity=0.3,
    x0 = 0, x1=0,
    x1 = 5,y1 = 5
)

reg_tree_plot <- plot_ly() %>%
    add_trace(x=~Xn[0:63], y=~Yn[0:63], type='scatter', width=700, height=500)

tree_layout <- layout(reg_tree_plot, shapes=edge_shapes)
x <- tree_layout
y <- tree_layout
z <- tree_layout

sub <- subplot(tree_layout,y,z,x,
              nrows=2,
              margin=0.05,
              shareX=FALSE,
              shareY=FALSE)

2 Answers
Related