-
Notifications
You must be signed in to change notification settings - Fork 249
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
CarioPlot with vertex labels has plots interact within a Jupyter Notebook in VSCode #638
Comments
I think it's related to #145 and #243, both of which are related to the fact that Cairo-generated SVG files do not use unique IDs for the text nodes; well, the IDs are unique within one figure, but if you embed two Cairo-generated SVG files in the same DOM tree, the IDs would clash. A workaround was implemented in #148 where we instructed Jupyter to isolate each SVG file in an Is there a way to check the DOM in VS Code and confirm that the two figures are not placed in separate |
I've used the developer tools, and it seems like they are simply being embedded using |
Yes, that's most likely the reason, but it's good to know that our workaround does not work for VS Code. Given the growing popularity of VS Code's embedded Jupyter notebook, I'll keep this issue open in case we come up with a suitable workaround. One possibility is to manually replace the glyph IDs in the generated SVG snippet with simple search-and-replace (similarly to how it's done here in a Julia library), but I'm a bit worried that we accidentally replace something that is not a glyph ID, or that the whole solution breaks if Cairo suddenly starts to use some other format for glyph IDs. |
@8uurg are you aware that igraph supports matplotlib and plotly now? Would that be an option for you? Edit: typo |
@iosonofabio I have switched to matplotlib for visualizations in the notebook as a workaround, which I can confirm works just fine. :) |
Fantastic. We're debating switching on matplotlib as the default plotting backend, this would be a +1 I guess |
I'm getting the same problem but with edge_label with the cairo backend in vscode jupyter notebooks. |
Have you tried the matplotlib backed? Esp. the current main version from GitHub has that logic strenghtened |
Yeah matplotlib works (release 0.10.4). The only issue I have is that the figsize setting doesn't work properly (it always forces a square figure size for some reason?). |
Great to hear. Matplotlib itself has many backends including vector graphics ones, so if you choose one of those (e g. Qt) it will have infinite resolution. The aspect ratio of the axes can also be set easily, just Google matplotlib set aspect. |
even when using inline, you can specify matplotlib's dpi resolution at the beginning of the notebook AFAIK. As for the aspect ratio, fair enough. let me look into it |
@alex180500 could you please share a minimal example so I can run it on my machine? |
Trying to separate the jupyter blocks here! import igraph as ig
import matplotlib.pyplot as plt
g = ig.Graph.Lattice([4, 4], circular=False)
g.es["label"] = [edge.tuple for edge in g.es]
g.es["label_size"] = 8
g.vs["label"] = g.vs.indices
g.vs["label_size"] = 8 # cairo
ig.plot(g, layout="grid", vertex_size=15, bbox=(500, 250)) # matplotlib
fig, ax = plt.subplots(figsize=(8, 8), dpi=100)
ig.plot(g, target=ax, layout="grid", vertex_size=0.2)
ax.set_aspect(0.5) It would be nice that in the end matplotlib could output the same as Cairo by using an argument like bbox or something similar. There should be an "easy" way to have the same output as Cairo. |
Thanks! Agreed, this could be improved. Matplotlib is quite a little more complex than the way we use Cairo, because of its interactive nature, so bboxing is not that easy. But I'm testing options right now, will keep you posted. edit: perhaps useful https://stackoverflow.com/questions/11995148/plot-circle-on-unequal-axes-with-pyplot |
@alex180500 I opened #665 to discuss this issue specifically, so let's stop that discussion here (theoretically, this issue is about labels, not stretchy circles) and continue over there. If Thomas Caswell from matplotlib intervenes that'd be useful, in any case let's hear from a few more devs what they think and plan ahead. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
Describe the bug
CarioPlot with vertex labels has plots interact within a Jupyter Notebook in VSCode. For example, the labels on the second plot are messed up (should state "hi!" instead of a 0 and what looks like a 1 & 2 merged together) - if I clear the cell above, removing the plot, the second plot fixes itself:
(Sidenote, it seems to mess up on Gist as well. I have not been able to reproduce the issue in jupyter lab.)
Possibly related to #623.
To reproduce
See the following gist.
https://gist.github.com/8uurg/9b443d1e1d790349e6ca09ef81cccb7a
Version information
The text was updated successfully, but these errors were encountered: