# Graph layout algorithm allowing manual adjustments?

**URL:** <https://discourse.julialang.org/t/graph-layout-algorithm-allowing-manual-adjustments/68164>\
**Category:** Visualization\
**Tags:** graph-layout\
**Created:** [September 14, 2021, 6:43pm UTC](https://discourse.julialang.org/t/graph-layout-algorithm-allowing-manual-adjustments/68164 "2021-09-14T18:43:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [September 14, 2021, 6:43pm UTC](https://discourse.julialang.org/t/graph-layout-algorithm-allowing-manual-adjustments/68164/1 "2021-09-14T18:43:13Z")

</div>

Julia packages like GraphPlot and NetworkLayout can automatically choose the positions of graph vertices to make the graph look nice. However, sometimes I want to manually adjust the positions of the vertices to make the layout more “perfect”, for presentation purposes. Is there any package which allows me to use the mouse to drag the vertices around after the graph is plotted? Alternatively, can I type in the desired coordinates of a subset of points (e.g. I may want several points to lie on a circle) and ask the graph layout algorithm to choose the positions of the remaining points in a way that’s “compatible” with the manual choices already made?

Suggestions outside the Julia ecosystem are also welcome. I’m desperate to get this functionality from anywhere.

---

<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 14, 2021, 7:45pm UTC](https://discourse.julialang.org/t/graph-layout-algorithm-allowing-manual-adjustments/68164/2 "2021-09-14T19:45:13Z")

</div>

GraphMakie.jl does I think 😉

---

<div class="post-metadata">

**Author:** ![hexaeder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexaeder/32/24403_2.png) [@hexaeder](https://discourse.julialang.org/u/hexaeder)\
**Post date:** [September 14, 2021, 9:16pm UTC](https://discourse.julialang.org/t/graph-layout-algorithm-allowing-manual-adjustments/68164/3 "2021-09-14T21:16:49Z")

</div>

Yes you can! More detail on how to do this in GraphMakie:

```julia
fig, ax, p = graphplot(g)

```

you can access the node positions as an [Observable](https://juliagizmos.github.io/Observables.jl/stable/) via `p[:node_pos]`.

So you can allways tweak them by setting

```julia
p[:node_pos][] = #any array of Point2f or Point3f

```

or adjust just a single node pos by

```julia
p[:node_pos][][4] = Point2f(0,0)
notify(p[:node_pos]) # trigger the update of the plot

```

You could also use the [node drag interaction](http://juliaplots.org/GraphMakie.jl/stable/#GraphMakie.NodeDrag), arrange the nodes by hand and call `p[:node_pos][]` afterwards to copy-past the final coordinates.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [September 15, 2021, 1:19pm UTC](https://discourse.julialang.org/t/graph-layout-algorithm-allowing-manual-adjustments/68164/4 "2021-09-15T13:19:12Z")

</div>

Thanks, that works nicely in the terminal and VSCode, but in Jupyter notebook I only get a static image embedded into the notebook. Is there a way to tell Jupyter that I want the figure to be displayed in a standalone window that supports the UI interactions like dragging?

---

<div class="post-metadata">

**Author:** ![hexaeder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexaeder/32/24403_2.png) [@hexaeder](https://discourse.julialang.org/u/hexaeder)\
**Post date:** [September 15, 2021, 1:40pm UTC](https://discourse.julialang.org/t/graph-layout-algorithm-allowing-manual-adjustments/68164/5 "2021-09-15T13:40:05Z")

</div>

I’ve never tried jupyter with julia so I am not sure how it works. Maybe you’re on `CairoMakie`? You could try

```julia
using GLMakie
GLMakie.activate!()

```

or maybe the same with `WGLMakie`?
