GraphRecipes.jl icon indicating copy to clipboard operation
GraphRecipes.jl copied to clipboard

Distance between nodes

Open Hofsmo opened this issue 4 years ago • 1 comments

Hi, I really like GraphRecipes for plotting smaller electric networks. However, when the number of vertices increases the graphs get unreadable. This could easily be fixed if I could change the distance between the vertices. I have been looking a lot, but not figured out to do this. I was therefore wondering if anyone knows how to change the distance between the vertices?

Cheers Sigurd

Hofsmo avatar May 14 '21 07:05 Hofsmo

The formatter tries to make the vertices as far apart as possible. You can change the method used with the method keyword argument, which may give a better layout for your graph. Other than that the two levers that I tend to use are the nodesize and the size of the plot, which gives the formatter more room to work with.

using Plots
using GraphRecipes
using LightGraphs

g = watts_strogatz(800,2,0.01)

Compare the following plots of the graph:

graphplot(g,method=:spring)

example

graphplot(g,size=(1000,1000),curvature=false,method=:spring,nodesize=0.05)

example

Beyond that, you could consider manually passing the x-y coordinates of the graph

JackDevine avatar May 20 '21 07:05 JackDevine