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

Add padding around graphplot to accommodate node size. #141

Open
mschauer opened this issue Sep 27, 2023 · 2 comments
Open

Add padding around graphplot to accommodate node size. #141

mschauer opened this issue Sep 27, 2023 · 2 comments

Comments

@mschauer
Copy link

I have this one

Screenshot 2023-09-27 at 10 04 34

I would like to fix the picture, so how can I resize?

As ad hoc fix I would like to do

   xlims!(ax, xl - padding, xu + padding)
   ylims!(ax, yl - padding, yu + padding)

but I cannot figure out how to access the default size.

@hexaeder
Copy link
Collaborator

hexaeder commented Sep 30, 2023

Not exactly the same, but here I posted a snippet on how to update the limits, such that all labels are within the limits.
I guess you could adapt that code?

In case you're creating a more general, nicer version of it (which also includes the sizes of the nodes), I'd be interested in the script. Either as an example in the docs or even as a lib function since this problem came up multiple times already.

@mschauer
Copy link
Author

I found a very stupid solution, but it did the trick

fig, ax, pl = graphplot(p(g))
hidedecorations!.(ax)
hidespines!(ax)
layout=pl[:node_pos][]
limsx = extrema(first.(layout)) .+ Float32[-1,1]
limsy = extrema(last.(layout))  .+ Float32[-1,1]
xlims!(ax, limsx...)
ylims!(ax, limsy...)

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

2 participants