# PlotlyJS: subplots and individual layouts

**URL:** <https://discourse.julialang.org/t/plotlyjs-subplots-and-individual-layouts/87740>\
**Category:** General Usage\
**Tags:** plotting, plotlyjs\
**Created:** [September 24, 2022, 12:04pm UTC](https://discourse.julialang.org/t/plotlyjs-subplots-and-individual-layouts/87740 "2022-09-24T12:04:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [September 25, 2022, 2:26pm UTC](https://discourse.julialang.org/t/plotlyjs-subplots-and-individual-layouts/87740/2 "2022-09-25T14:26:09Z")

</div>

The problem in my previous entry was not reproducible. It was entirely dependent on my data.

Below I present an MWE that can be easily reproducible.

1 - Defining shapes (two rectangles):

```julia
shapes1 = rect([5, 25], [10, 30],
                0, 1; fillcolor = "red", opacity = 0.1, line_width = 0,
                xref="x", yref = "paper");

```

2 - Producing the two individual plots:

```julia
function noise1()
    trace1 = scatter(;x=1:40, y=randn(40), name = "some")
    layout1 = Layout(;
	    shapes = shapes1,
	    title_text = "Some noise", 
	    title_x = 0.5,
	    hovermode = "x",
        titlefont_size = 16)
    fig1 = plot(trace1, layout1)
end
noise1()

function noise2()
    trace2 = scatter(;x=1:40, y=rand(40), name = "more")
    layout2 = Layout(;
		shapes = shapes1,
		title_text = "More noise", 
		title_x = 0.5,
		hovermode = "x",
        titlefont_size = 16)
   fig2 = plot(trace2, layout2)
end
noise2()

```

 ![a](https://global.discourse-cdn.com/julialang/original/3X/1/e/1ef4596976bad013da3d4b16c05acd274e8f0400.png)

3 - Creating the subplots

```julia
fig3= [noise1() noise2()]
relayout!(fig3, Layout(; hovermode="x", shapes = shapes1))
fig3

```

 ![b](https://global.discourse-cdn.com/julialang/original/3X/1/3/136477f30b35c6c4a37f3566ba5f78cfda56d82a.png)

The strange problem: why do `shapes` only appear in the first subplot? How can I force them to be in the second plot as well?  
Thanks

---

_[View the full topic](https://discourse.julialang.org/t/plotlyjs-subplots-and-individual-layouts/87740)._
