JuliaGraphs / GraphPlot.jl

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

Trouble fitting labels inside the picture #161

Closed PeterNorlindh closed 2 months ago

PeterNorlindh commented 2 years ago

I'm using draw(PNG("myGraph.png", 200, 200), gplot(g)) and have trouble fitting the nodelabels entirely inside the frame of the picture, see below. Is there a way to fix this?

Graph - Label does not fit

Thanks, this package is awesome!

hdavid16 commented 1 year ago

@PeterNorlindh a quick workaround would be to use join.(split.(labels,"_"),"\n"). This would split your labels by underscore and then join each segment on a newline.

hdavid16 commented 1 year ago

@PeterNorlindh

Another option is to use nodelabeldist along with nodelabelangleoffset to offset the labels:

As an example:

gplot(
    path_digraph(3), 
    [1,2,3], #x coord
    [1,2,3], #y coord
    nodelabel=["ABCDEFGHI","JKLMNOP","QRSTUVWXYZ"],
    nodelabeldist=[2.5,0,-2.7], #shift the first node 2.5 to the right, middle node 0 units, right node 2.7 to left
    nodelabelangleoffset=0 #label along the horizontal center line of the nodes
)

Will produce the plot:

image

If you are satisfied, feel free to close the issue. Thanks for the great question!

etiennedeg commented 2 months ago

Closed by #186