edge_weights property for graphplot()
Would like to be able to do something like this:
using MetaGraphs
using PlotRecipes
g = MetaGraph(5)
add_edge!(g, 1,2)
add_edge!(g, 1,3)
add_edge!(g, 3,4)
set_prop!(g, Edge(1,2), :weight, 2.)
set_prop!(g, Edge(1,3), :weight, 3.)
set_prop!(g, Edge(3,4), :weight, 4.)
graphplot(g, edge_weights=([get_prop(g, e, :weight) for e in edges(g)], 0.5, :BrBG))
to set different sized lines for different edges. There's a node_weights property, so why not edge_weights?
You should in principle be able to do this with linewidth (which is a standard Plots keyword for the width of lines) but there seems to be something in the recipe that breaks it.
It's because linewidth doesn't accept a Vector. Solutions including adding that capability to Plots (might be possible using the same logic @daschw used to implement different colors for segments); or to make each edge it's own series here in GraphPlot.
@mkborregaard Can you point me to the PR for segment colors? I'll take a look and see if I can replicate.
It was this one https://github.com/JuliaPlots/Plots.jl/pull/1110 which had to be supplemented with https://github.com/JuliaPlots/Plots.jl/pull/1142/files for GR as there were some unfortunate side effects. Not sure just replicating this will work, though.
I think implementing each edge as it's own series would work, though care must be taken not to screw up the line_z functionality. It's not an easy thing to do :-)
Oh - I thought you meant that a color/line segment had been implemented for graphplot specifically... this is something else. I'll take a look and see what makes sense. Could it be that adding some separate logic for graph plots while disabling stuff like line_z makes sense?
It might be but the philosophy of Plots is to generally mostly use the existing keywords so you don't have to learn bespoke keywords for each use.
Digging up a slightly old issue here.
The desired functionality exsists:
using MetaGraphs
using LightGraphs
using GraphRecipes
using Plots
g = MetaGraph(5)
add_edge!(g, 1,2)
add_edge!(g, 1,3)
add_edge!(g, 3,4)
set_prop!(g, Edge(1,2), :weight, 2.)
set_prop!(g, Edge(1,3), :weight, 3.)
set_prop!(g, Edge(3,4), :weight, 4.)
graphplot(g, edge_width=(s,d,w) -> get_prop(g, Edge(s,d), :weight))
Although the API is not quite the same as the one from the OP. I have wondered if it would be a good idea to let users store formatting suggestions in a MetaGraph in some sort of standard format and have graphplot parse that information and produce the right keyword arguments. In my proposed idea, the above example would become:
using MetaGraphs
using LightGraphs
using GraphRecipes
using Plots
g = MetaGraph(5)
add_edge!(g, 1,2)
add_edge!(g, 1,3)
add_edge!(g, 3,4)
set_prop!(g, Edge(1,2), :edge_width, 2.)
set_prop!(g, Edge(1,3), :edge_width, 3.)
set_prop!(g, Edge(3,4), :edge_width, 4.)
graphplot(g)