graphjulialabelgraphplot

GraphPlot - Having nodelabels inside of node when graph's size greather than 100


The following MWE:

using Graphs
using GraphPlot, Compose, Cairo, Fontconfig

n = 100
inst_graph = SimpleGraph(n)
nodesize = 5ones(Float64, n)
nodelabelsize = 0.02*ones(Float64, n)
draw(PDF("test.pdf"), gplot(inst_graph, nodelabelsize=nodelabelsize, nodelabel=1:n, nodesize=nodesize))

Produces the following graph:

enter image description here

Which I would like to have the nodelabels strictly within the nodes. I tried many values for nodesize and nodelabelsize ranging from -2 to 5 but nothing worked. I noticed that for smaller values of n it does work, but the graphs I want to display have at least 100 nodes.

Example with n=40 which is still not perfect as the labelnode are just a little outside the nodes! enter image description here

Note that what I tried to do is from GraphPlot doc with more nodes:

enter image description here


Solution

  • Set the size of your canvas so all fits:

    draw(PDF("test.pdf",30cm, 20cm), gplot(inst_graph, nodelabelsize=nodelabelsize, nodelabel=1:n, nodesize=nodesize))
    

    enter image description here