JuliaGraphs / GraphPlot.jl

Graph visualization for Julia.
http://JuliaGraphs.github.io/GraphPlot.jl/
Other
201 stars 62 forks source link

Node colors does not work for large graphs on Jupyter/IJulia #62

Closed Jacob-Stevens-Haas closed 6 years ago

Jacob-Stevens-Haas commented 6 years ago

I'm looking at a version of the connectome("neural wiring") of the C. elegans worm, a graph of 297 vertices. I'm trying to display the graph with each vertex colored according to it's eccentricity, with more central vertices in a hotter color.

However, gplot() colors each node black, even with the nodefillc parameter assigned. It seems that this is an issue with plotting large graphs. Test code, adapted from the documentation:

using LightGraphs
using GraphPlot

n=195
g=erdos_renyi(n,.05)
membership=rand([1,2], nv(g));
nodecolor = [colorant"lightseagreen", colorant"orange"]
nodefillc = nodecolor[membership]
gplot(g, nodefillc=nodefillc)

When n is larger than 195, the nodes are all filled in black, as opposed to green and orange.

sbromberger commented 6 years ago

I'm unable to reproduce (your code with n=300):

screen shot 2018-05-31 at 14 28 56

Jacob-Stevens-Haas commented 6 years ago

Thanks for the quick reply. How interesting. Are you using something other than the Colors package? I added it to the previous post. Here's the images I'm getting, FYI: n=150 colored n=300 notcolored

Interestingly, when I use the other example from the documentation: nodefillc = distinguishable_colors((g), colorant"blue") it seems to work: verycolored In both cases, typeof(nodefillc) returns Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},1}. They're both length 300.

Edit: I'm using Jupyter notebooks. Judging by the background, you're using Juno? Let me try that.

sbromberger commented 6 years ago

Are you using something other than the Colors package?

Not that I'm aware.

I was doing this within vscode, so maybe that makes a difference?

Jacob-Stevens-Haas commented 6 years ago

Struggling to get plots working in Juno. Can GraphPlot work as a backend to Plots.jl? I see your examples on other issues reference Compose.jl, rather than Plots.jl

EDIT: I was able to get draw(SVG("testplot2.svg", 8cm, 8cm), gplot(g, nodefillc=nodefillc)) to work.
Opening the file, I see that the vertices are colored correctly. (still could use help displaying in the plots window in Juno or as a gui in the REPL)

That being said, this issue clearly applies to the Jupyter/IJulia+GraphPlot combination. I'll update the title accordingly. Not sure exactly how gplot() works, so I don't know if it's a problem with large Compose objects, specifically with gplot, or with IJulia.

I'm relatively new to GraphPlot, so I'll try other node and edge parameters to see if they also break with large graphs

sbromberger commented 6 years ago

Since this isn't specific to gplot, I think we can close this out. It's more likely some bug in jupyter/ijulia or some strange edge case. Let me know if you'd like to continue troubleshooting and I'm happy to reopen.

dmos62 commented 4 years ago

Can still reproduce. Also unsure where the cause is. I've a new clue though. Currently I'm rendering to file as a workaround, but I've noticed that if I render the same plot object (the return value of gplot(...) call) more than once, after the first time the nodes will be colored black. Using JupyterLab.

My snippet:

p = gplot(sg, nodefillc=nodefillc);
draw(SVG("plot.svg", 50cm, 50cm), p);