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

Bug in igraph.plot() in jupyter #243

Closed
Benfeitas opened this issue Aug 22, 2019 · 13 comments
Closed

Bug in igraph.plot() in jupyter #243

Benfeitas opened this issue Aug 22, 2019 · 13 comments

Comments

@Benfeitas
Copy link

I'm running python igraph in jupyter, and found a weird bug:

When I include the 2nd cell (the one after package importing), running the 3rd cell renders weird labels.
Screenshot 2019-08-22 at 16 53 42

However, deleting the 2nd cell renders everything normally. I have tried copying all these cells to a new notebook but to no avail.
Untitled2.ipynb.zip

I'm attaching a .ipynb with all cells, hopefully you can reproduce this issue.

@Benfeitas
Copy link
Author

Benfeitas commented Aug 22, 2019

To note, the labels on the 2nd plot are changed automatically as soon as I evaluate the first one. I.e. commenting the line ig.plot(g2, ...) fixes the issue.

@Benfeitas Benfeitas changed the title Vertex labeling issue: vertices showing weird labels Bug in igraph.plot() in jupyter Aug 22, 2019
@vtraag
Copy link
Member

vtraag commented Aug 22, 2019

I'll have to look into it further, but at first sight it seems related to issue #222.

@iosonofabio
Copy link
Member

I agree that seems to be the thing.Good ol' HTML/JS not having namespaces makes everything global and prone to these kinds of corruptions.

One suggestion was we reparse the svg file coming out of Cairo and make the node ids unique. Doable if a bit dirty.

@vtraag
Copy link
Member

vtraag commented Aug 22, 2019

It might also be an option to simply default to PNG for displaying in Jupyter notebooks, see also #36. I'm not sure how matplotlib handles this.

@ntamas
Copy link
Member

ntamas commented Aug 22, 2019

Apparently IPython (and most likely Jupyter) can wrap SVGs inside an iframe to avoid these kinds of corruptions, see this PR. I haven't had time to deal with it, most likely we should read the PR and see how we can give hints to IPython that our graphs should be placed in iframes.

@ntamas
Copy link
Member

ntamas commented Aug 22, 2019

Actually, here's the solution. Anyone willing to pick this up? :)

@vtraag
Copy link
Member

vtraag commented Aug 22, 2019

It seems that is already merged in PR #148?

@vtraag
Copy link
Member

vtraag commented Aug 22, 2019

Btw, it seems that matplotlib uses a salt for the IDs: https://github.com/matplotlib/matplotlib/blob/477c1dcbe1a6aaed57d2e4b7210b47a6e8d4d73d/lib/matplotlib/backends/backend_svg.py#L317. Perhaps that is also a good suggestion for the long term for cairo.

@ntamas
Copy link
Member

ntamas commented Aug 22, 2019

Well, it's been a long time ;) It could be the case that the fix is already merged. In that case, we only need to wait until 0.8.0 is released; in the meanwhile, @Benfeitas can use PR #148 as a workaround.

@ntamas ntamas closed this as completed Aug 22, 2019
@vtraag
Copy link
Member

vtraag commented Aug 23, 2019

I guess we can also close #36, pointing to PR #148?

@ntamas
Copy link
Member

ntamas commented Aug 24, 2019 via email

@vtraag
Copy link
Member

vtraag commented Aug 24, 2019

Sorry, wrong number :) I meant #222 instead of #36.

@ntamas
Copy link
Member

ntamas commented Aug 24, 2019 via email

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

4 participants