Help using GraphMakie to emulate GraphRecipes plot using edge_width and number of edges

Hello!

I started using GraphMakie mostly due to this issue here: Dots in the middle of nodes · Issue #154 · JuliaPlots/GraphRecipes.jl · GitHub

Dots in the middle of labels, which afaik, persists to today. I therefore resorted to GraphMakie as in the first code example, but could not figure out how to reproduce the GraphRecipes example. In particular, there are two issues;

  1. How can I make, with GraphMakie, two arrows per pair of nodes, if they have connections in either direction as in the GraphRecipes example? I am currently getting only single arrows in GraphMakie.

  2. How can I control the width of the connections to visualise the strength of the connections?

I am attaching two fully reproducible examples alongside with the csv files.

  1. GraphMakie example, run this one first so it loads the csv files
using Colors, ColorSchemes
c = eigenvector_centralities[:,:LogCentrality];
cs = ColorScheme([colorant"white", colorant"orange"]);
colors = get.(Ref(cs), (c .- minimum(c)) ./ maximum(c))
using CairoMakie, GraphMakie, Graphs, SimpleWeightedGraphs, GraphMakie.NetworkLayout, DataFrames
using CSV
graph_estimate_read = CSV.File("graph_estimate.csv") |> Tables.matrix
eigenvector_centralities = DataFrame(CSV.File("network_statistics.csv"))
p=7;
g = SimpleWeightedDiGraph(p);
width_vec = 1 .+ zeros(2*p);
width_vec[1:7] =  ones(p);
k=1
for i in 1:p, j in i+1:p
    add_edge!(g,i,j,graph_estimate[i,j]);
    add_edge!(g,j,i,graph_estimate[j,i]);
    #width_vec[k] = graph_estimate[i,j];
    k += 1;
    #width_vec[k] = graph_estimate[j,i];
    k += 1;
    #println("i ",i," j ",j," ",graph_estimate[i,j])
end
label_table = select(eigenvector_centralities,:NodeOld,:NodeNew,:country)
sort!(label_table,:NodeNew,rev=false);
#layout=(args...)->spring_layout(args...; C=10)
#network_graph = gplot(g,layout=layout,nodelabel=label_table[:,:country],nodelabeldist=0)
#layout = SquareGrid(cols=7)
#layout = SFDP(Ptype=Float32, tol=0.01, C=0.2, K=1)
#layout = Spectral(dim=2,nodeweights = c)
layout = SFDP(Ptype=Float32, tol=0.01, C=0.2, K=1)
mygr = GraphMakie.graphplot(g,
        node_size = 10*exp.(c),
          ilabels = eigenvector_centralities[:,:country],
          ilabels_color = :black,
          node_color = colors,
          arrow_shift=:end,
          layout=layout)

and the GraphRecipes example (make sure to run the above first to get the required vectors etc. allocated.

using GraphRecipes

GraphRecipes.graphplot(g,
                        node_weights = c,
                        names  = eigenvector_centralities[:,:country],
                        nodeshape = :circle,
                        nodesize = 0.6,
                        nodecolor = colors,
                        edgewidth = (s,d,w) -> 200*graph_estimate[s,d],
                        method=:sfdp)

Thank you so much!

PS: Given that I cannot upload CSV files, here is graph_estimate.csv

x1,x2,x3,x4,x5,x6,x7
0.0,0.0028940565738803103,0.002959734852673479,0.0038252421402493186,-0.0008326586791404967,0.00014882271273678472,0.0007928348891374393
0.003766108542560098,0.0,0.007446995453767402,0.0020949024317352682,0.005709680055675159,0.0007431761740365417,0.004567554779221506
0.007469027444890952,0.00646157711622215,0.0,0.007184718674669699,0.008653510498042527,0.005775878911605359,-0.005615583467655072
0.004795773683754656,0.0036156858550579264,0.0018934061537301482,0.0,0.002640220106916902,0.000529859826660628,0.013450272883401093
-0.0025768559725098507,0.004459995093331748,0.007245982344457213,-0.00016918996783604756,0.0,0.0017050113029466018,0.002928921206218105
0.006798783052828328,0.008206471860136084,0.005219032452258232,0.013148147003536188,0.004493258725941818,0.0,0.005914348412100756
0.004337008604745518,0.0015723834728439857,-0.003445121287789976,0.009232463840824212,-0.0008406701411173944,0.0018415830429915458,0.0

and network_statistics.csv

NodeOld,NodeNew,country,LogCentrality,LogCentrality_upper,LogCentrality_error
9.0,6.0,F,1.429261749636262,7.933738394928697,6.504476645292435
3.0,3.0,C,1.270664935323544,7.9028730753583645,6.6322081400348205
2.0,2.0,B,0.9391597682260547,7.564161931031742,6.625002162805687
5.0,5.0,E,0.7205033438365475,7.43033481633809,6.709831472501542
4.0,4.0,D,0.6949029817355276,7.009933824386254,6.315030842650726
1.0,1.0,A,0.1704419946180868,6.719985765519242,6.549543770901155
11.0,7.0,G,0.0,0.0,0.0

This is the plot I want to modify:


This is the plot I want to emulate (notice the unsightly dots in the middle of the node labels).
gr

A couple things I can think of:

  1. It looks like your double edges are not using curves; use the curve_distance parameter to make them curve a bit more!
    See Feature Walkthrough · GraphMakie.jl
  2. Your node_size should probably be larger :smiley:
  3. You probably want to set elabels_color to have some transparency from the same parameter you are using for the edge width!