# Replacing a node in a ComputeGraph (Makie)

**URL:** <https://discourse.julialang.org/t/replacing-a-node-in-a-computegraph-makie/132743>\
**Category:** Visualization\
**Created:** [September 29, 2025, 10:07am UTC](https://discourse.julialang.org/t/replacing-a-node-in-a-computegraph-makie/132743 "2025-09-29T10:07:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rasmushenningsson](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rasmushenningsson](https://discourse.julialang.org/u/rasmushenningsson)\
**Post date:** [September 29, 2025, 10:07am UTC](https://discourse.julialang.org/t/replacing-a-node-in-a-computegraph-makie/132743/1 "2025-09-29T10:07:34Z")

</div>

Is there any way to replace a node in a ComputeGraph?  
Let’s say I want to replace an input node with a computed value, but I do not want to delete all the dependent nodes and recreate them.

# Example

Given this graph:

```julia-auto
graph = ComputeGraph()
add_input!(graph, :A, 1)
add_input!(graph, :B, 2)
register_computation!(graph, [:A, :B], [:C]) do inputs, changed, cached
    return (inputs.A[] + inputs.B[], )
end

```

Is it possible to transform it into:

```julia-auto
graph2 = ComputeGraph()
add_input!(graph2, :A, 1)
add_input!(graph2, :X, 2)
register_computation!(graph2, [:X], [:B]) do inputs, changed, cached
    return (inputs.X[]*100, )
end
register_computation!(graph2, [:A, :B], [:C]) do inputs, changed, cached
    return (inputs.A[] + inputs.B[], )
end

```

**without** deleting and recreating the node `:C`?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 29, 2025, 11:27am UTC](https://discourse.julialang.org/t/replacing-a-node-in-a-computegraph-makie/132743/2 "2025-09-29T11:27:52Z")

</div>

No not really and there likely wont be.  
Btw, using ComputeGraph outside `plot.attributes` isn’t totally recommended, since we’re not entirely sure in which direction the compute graph will go and how to manage its life cycle outside of plot recipes.  
Best only do it when you have a strong reason for it.

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [September 29, 2025, 12:30pm UTC](https://discourse.julialang.org/t/replacing-a-node-in-a-computegraph-makie/132743/3 "2025-09-29T12:30:58Z")

</div>

I was also looking for such functionality recently… Basically, to “insert” a step between existing calculations in a plotting setup.

---

<div class="post-metadata">

**Author:** ![rasmushenningsson](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rasmushenningsson](https://discourse.julialang.org/u/rasmushenningsson)\
**Post date:** [September 29, 2025, 2:05pm UTC](https://discourse.julialang.org/t/replacing-a-node-in-a-computegraph-makie/132743/4 "2025-09-29T14:05:48Z")

</div>

Thanks for the input!

This is for modifying the “axis” plot object of an `LScene`. That is, let’s say I have

```julia-auto
fig = Figure()
ax = fig[1,1] = LScene(fig)
p = only(ax.scene.plots)

```

and I want the `axisnames` (labels for each axis) to depend on something.  
I am able to access this as an `Observable` using

```julia-auto
p.attributes.inputs[:names].value.axisnames

```

and by modifying that (e.g. using `connect!`), I can achieve what I want right now.

So maybe my question is more about the long term relationship between `Observable`s and `ComputeGraph`. My impression (perhaps incorrectly) was that in the long run, we should prefer to remove `Observable`s and implement as much as possible using the `ComputeGraph` directly - to avoid e.g. problems with updates that need to be synchronous.

And if later, `axisnames` is implemented with `Observable`s, I wouldn’t be able to make it depend on something computed - without replacing the node in the compute graph.
