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

Trouble fitting labels inside the picture

Open PeterNorlindh opened this issue 3 years ago • 2 comments

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!

PeterNorlindh avatar Nov 19 '21 17:11 PeterNorlindh

@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 avatar Jul 27 '22 01:07 hdavid16

@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!

hdavid16 avatar Jul 27 '22 04:07 hdavid16

Closed by #186

etiennedeg avatar May 12 '24 13:05 etiennedeg