JuliaGraphs / GraphPlot.jl

Graph visualization for Julia.
http://JuliaGraphs.github.io/GraphPlot.jl/
Other
200 stars 62 forks source link

[feature request] allow user to adjust edge stroke styles by passing a vector as a kwarg #155

Open SimonEnsemble opened 2 years ago

SimonEnsemble commented 2 years ago

would be cool to be able to change the edge strokes as dashed, dotted, etc. to denote different classes of edges. e.g. I want to illustrate that there is not a path between v_1 and v_3. would be cool to be able to connect v_1 and v_3 with a dashed edge line. (I know you can adjust edge colors, but edge stroke would be great too.)

image

hdavid16 commented 1 year ago

This will get fixed in: https://github.com/JuliaGraphs/GraphPlot.jl/pull/176

hdavid16 commented 1 year ago

@SimonEnsemble , Since PR #176 hasn't been reviewed. You can accomplish this with GraphMakie:

using Graphs, GraphMakie, GLMakie, LaTeXStrings

g=SimpleGraph(Edge.([(1,2),(1,3),(3,4),(3,5),(4,5)]))

graphplot(g,
    node_size=40,
    node_color=:white,
    node_attr=(strokecolor=:black, strokewidth=5),
    nlabels=[L"v_%$i" for i in vertices(g)], #use latex for labels
    nlabels_align=(:center,:center),
    edge_attr=(linestyle=[e==Edge(1,3) ? :dash : :solid for e in edges(g)],), #set dashed edge for 1-3 edge
    edge_plottype=:beziersegments #lets you set edge specific properties
)

You'll get the following plot: image