Graph Plot with Custom Nodes

Hi all :slight_smile:

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

1 Like

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 …

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.

Judging from this open issue I’m guessing that you can’t at the moment draw custom node shapes in GraphPlot.jl.

If you use Plots.jl’s GraphRecipes 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 for details.

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

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 
    )

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!

1 Like