# PlotlyJS update subplot traces in-place

**URL:** https://discourse.julialang.org/t/plotlyjs-update-subplot-traces-in-place/130432
**Category:** Visualization
**Tags:** plotlyjs
**Created:** [July 2, 2025, 8:24pm UTC](https://discourse.julialang.org/t/plotlyjs-update-subplot-traces-in-place/130432 "2025-07-02T20:24:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rand5](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rand5/32/867_2.png) [@rand5](https://discourse.julialang.org/u/rand5)
#### Post date: [July 2, 2025, 8:24pm UTC](https://discourse.julialang.org/t/plotlyjs-update-subplot-traces-in-place/130432/1 "2025-07-02T20:24:01Z")

</div>

In PlotlyJS, I can update a trace in-place using `react!()` as mentioned in the docs:

```julia
tr = scatter(;y=rand(5))
p = plot(tr)
tr[:y] .= rand(5)
react!(p,[tr],Layout())

```

However, I don’t see any information on how to do in-place updating of subplot data. For example:

```julia
p = make_subplots(rows=2, cols=1, shared_xaxes=true, vertical_spacing=0.02)
tr1 = scatter(;y=rand(5))
tr2 = scatter(;y=rand(10))
add_trace!(p, tr1, row=1, col=1)
add_trace!(p, tr2, row=2, col=1)
p

```

The goal is then to do something like

```julia
tr1[:y] .= rand(5)
react!(p,[tr1],row=1,col=1)

```

but `react!` doesn’t take row/col keywords. I’d like to avoid redrawing the whole plot.  
Any help is greatly appreciated!

---

<div class="post-metadata">

### Author: ![rand5](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rand5/32/867_2.png) [@rand5](https://discourse.julialang.org/u/rand5)
#### Post date: [July 2, 2025, 8:35pm UTC](https://discourse.julialang.org/t/plotlyjs-update-subplot-traces-in-place/130432/2 "2025-07-02T20:35:43Z")

</div>

The solution I found is to not use the `make_subplots()` function, and instead use the lower level API mentioned at the bottom of this page: [Subplots in Julia](https://plotly.com/julia/subplots/)

A MWE is then:

```julia
tr1 = scatter(;y=rand(5))
tr2 = scatter(;y=rand(10),yaxis="y2")
L1 = Layout(yaxis_domain=[0, 0.5], yaxis2_domain=[0.51, 1], yaxis2_anchor="x2")
p = plot([tr1,tr2],L1)

```

with the update step

```julia
tr2[:y] .= rand(10)
react!(p,[tr1, tr2],L1)

```
