Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble fitting labels inside the picture #161

Closed
PeterNorlindh opened this issue Nov 19, 2021 · 3 comments
Closed

Trouble fitting labels inside the picture #161

PeterNorlindh opened this issue Nov 19, 2021 · 3 comments

Comments

@PeterNorlindh
Copy link

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
Copy link
Contributor

@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
Copy link
Contributor

hdavid16 commented Jul 27, 2022

@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
Copy link
Member

Closed by #186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants