# Colouring edges in GraphMakie.jl

**URL:** <https://discourse.julialang.org/t/colouring-edges-in-graphmakie-jl/109082>\
**Category:** Visualization\
**Tags:** plotting, makie, graphs\
**Created:** [January 22, 2024, 3:51am UTC](https://discourse.julialang.org/t/colouring-edges-in-graphmakie-jl/109082 "2024-01-22T03:51:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahnoor\_Pop](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mahnoor_pop/32/205364_2.png) [@Mahnoor\_Pop](https://discourse.julialang.org/u/Mahnoor_Pop)\
**Post date:** [January 22, 2024, 3:51am UTC](https://discourse.julialang.org/t/colouring-edges-in-graphmakie-jl/109082/1 "2024-01-22T03:51:59Z")

</div>

Hi! I’m making a graph based on an adjacency matrix of 1’s and 2’s (which indicates which colour the edge should be). Currently, I can’t colour individual edges like shown in the third example of [this page](https://graph.makie.org/stable/generated/plots/).

I think this is because I’m using graphplot!(ax, …) instead of f, ax, p = graphplot() because I have multiple axes that I’m plotting. I don’t know how to use f, ax, p = graphplot() and then put that into a gridlayout().

```julia
g = SimpleDiGraph(ODENetworkModel.num_nodes)
fig = Figure(size = (1920, 1080))

# create graph visualisation
ax1 = Axis(network_and_init[1,1], title = "$(ODENetworkModel.num_nodes) Node System", width = 250, height = 250, xrectzoom = false, yrectzoom = false)
println("Created network...")
edge_colours = []

for i in 1:ODENetworkModel.num_nodes
    for j in 1:ODENetworkModel.num_nodes
         if ODENetworkModel.adj_matrix[i,j] == 1
            add_edge!(g, i, j)
            push!(edge_colours,1)
        elseif ODENetworkModel.adj_matrix[i,j] == 2
            add_edge!(g, i, j)
            push!(edge_colours,2)
        end
    end 
end

p = graphplot!(ax1, g, ilabels = [i for i in 1:ODENetworkModel.num_nodes], nlabels = parameter_labels(ODENetworkModel.num_nodes, ODENetworkModel.par_adj_matrix))
    
# trying to change the colour of JUST some edges, but this doesn't work because I need to use graphplot, but I can't do that because I need to put it into the right gridlayout
# for edge in 1:length(edge_colours)
# if edge_colours[edge] == 2
# p.edge_color[][edge] = :red
# end
# end
p.edge_color[] = :red # turns all of the edges red...
p.edge_color = p.edge_color[] # trigger observable

```

I thought that p.edge\_color was a list of Symbols (colours)? But in my code it is just one colour…

Many thanks 🙂

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 6, 2024, 2:42pm UTC](https://discourse.julialang.org/t/colouring-edges-in-graphmakie-jl/109082/2 "2024-03-06T14:42:10Z")

</div>

Hi, you might get more answers if you give a complete minimal example that we can run on our side to investigate…

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [March 9, 2024, 11:50pm UTC](https://discourse.julialang.org/t/colouring-edges-in-graphmakie-jl/109082/3 "2024-03-09T23:50:33Z")

</div>

Try to pass `edge_color::Vector` as a keyword argument to `graphplot!`.
