# Graph Plot with Custom Nodes

**URL:** <https://discourse.julialang.org/t/graph-plot-with-custom-nodes/100446>\
**Category:** General Usage\
**Tags:** package, plotting, visualization, compose\
**Created:** [June 16, 2023, 12:03pm UTC](https://discourse.julialang.org/t/graph-plot-with-custom-nodes/100446 "2023-06-16T12:03:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flobe](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@flobe](https://discourse.julialang.org/u/flobe)\
**Post date:** [June 16, 2023, 12:03pm UTC](https://discourse.julialang.org/t/graph-plot-with-custom-nodes/100446/1 "2023-06-16T12:03:00Z")

</div>

Hi all 🙂

I’m currently working with `GraphPlot.jl` to visualize my data - works fine. However I want to enrich the visualization so that you can see the confidence of the nodes/data in the graph during the simulation. I was thinking of a filling circle in each node. To test it, I have already implemented it using `Compose.jl`.

I would like to pass these custom nodes to my existing code with `GraphPlot.jl`, so that I can continue to use all the functionality of `GraphPlot.jl` and do not have to draw each edge myself.

Since GraphPlot is also using Compose, I guess it should be possible, but I have no idea how to start … has anyone an idea?

Thanks!

![anim_test](https://global.discourse-cdn.com/julialang/original/3X/a/c/ac08bf89ed1680546f481abf1fc4e144b8027490.gif)

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [June 18, 2023, 12:37pm UTC](https://discourse.julialang.org/t/graph-plot-with-custom-nodes/100446/2 "2023-06-18T12:37:49Z")

</div>

if you’re wanting a “live” display that updates while your code runs, you probably need Makie. I would guess that other graph drawing packages would output only single PNG or SVG images …

---

<div class="post-metadata">

**Author:** ![flobe](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@flobe](https://discourse.julialang.org/u/flobe)\
**Post date:** [June 19, 2023, 6:38am UTC](https://discourse.julialang.org/t/graph-plot-with-custom-nodes/100446/3 "2023-06-19T06:38:57Z")

</div>

Ah maybe I expressed myself misunderstandable. The problem is not the live animation but the custom nodes. If each frame is saved as a png/svg and I only have the visualisation afterwards, I am completely satisfied.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [June 19, 2023, 8:22am UTC](https://discourse.julialang.org/t/graph-plot-with-custom-nodes/100446/4 "2023-06-19T08:22:24Z")

</div>

Judging from [this open issue](https://github.com/JuliaGraphs/GraphPlot.jl/issues/142) I’m guessing that you can’t at the moment draw custom node shapes in GraphPlot.jl.

If you use Plots.jl’s [GraphRecipes](https://docs.juliaplots.org/dev/generated/graph_attributes/#graph_attributes) you can specify `node shape` - this may accept custom shapes.

If you use GraphMakie.jl you should be able to use custom marker shapes using eg `graphplot(g, node_attr=(marker=...` - see [the docs](https://docs.makie.org/stable/examples/plotting_functions/scatter/index.html#scatter) for details.

If you use Karnak.jl (which I’m more familiar with) you can pass a function to the `vertexshapes` keyword:

```julia
drawgraph(g,
    vertexshapes = (v) -> begin
            sethue("grey30")
            circle(O, node_radius, :fill)
            sethue(HSL(360rand(), 0.8, 0.7))
            pie(O, node_radius, 0, rand() * 2π, :fill)
        end 
    )

```

 ![Screenshot 2023-06-19 at 09.19.33](https://global.discourse-cdn.com/julialang/original/3X/a/c/acbc8935dbe009dfcd400dd4dabbdabd2f006fdb.png)

---

<div class="post-metadata">

**Author:** ![flobe](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@flobe](https://discourse.julialang.org/u/flobe)\
**Post date:** [June 19, 2023, 8:36am UTC](https://discourse.julialang.org/t/graph-plot-with-custom-nodes/100446/5 "2023-06-19T08:36:10Z")

</div>

Thanks, I was not aware of the open issue and also of the package Karnak.jl (which is yours, I guess?). Seems very comprehensive, with lots of features - I’ll definitely try to get my head around it and give it a go!
