Skip to content

Instantly share code, notes, and snippets.

@cocomoff
Created December 3, 2019 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocomoff/0da9308bdb31ab9d50bf33e4ebe91ce4 to your computer and use it in GitHub Desktop.
Save cocomoff/0da9308bdb31ab9d50bf33e4ebe91ce4 to your computer and use it in GitHub Desktop.
Plots in Julia for graph visualizer (tentative)
1 2
1 3
2 4
3 4
3 5
4 5
using DelimitedFiles
using Plots
gr()
node_loc = readdlm("location.txt", Float64)[:, 2:end];
edges = readdlm("edge.txt", Int);
@show node_loc;
@show edges;
plot(leg=false)
x = node_loc[:, 1]
y = node_loc[:, 2]
for row in 1:size(edges)[1]
f, t = edges[row, :]
locF = node_loc[f, :]
locT = node_loc[t, :]
xs = [locF[1], locT[1]]
ys = [locF[2], locT[2]]
println("$f -> $t")
plot!(xs, ys, color=:black, lw=3)
end
scatter!(x, y, color=:red, z = 2, ms=10)
savefig("out.png")
1 1 2
2 2 3
3 3 5
4 2 0
5 1 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment