Search code examples
pythonigraphcairo

Why curved edges are invisible in igraph plotting?


In python igraph plotting with cairo PDF, curved edges set either by edge_curved = X or autocurve = True, edges are invisible in the PDF output. Same stands for PNG. Arrowheads and all other graphic elements are visible. Setting the edges straight, they become visible. Here is a minimal example:

import igraph
g = igraph.Graph.Erdos_Renyi(n = 23, m = 123)
igraph.plot(g, autocurve = True, edge_width = 0.02)

Solution

  • With edge width below 0.051 the curved edges are always invisible. Actually all edge widths >= 0.051 and < 1.0 looks the same on PDF, probably numbers below 1.0 are rounded up, and <= 0.05 rounded to 0.0. On PNG plots there is clear difference in this range of edge widths.

    So the solution is to use at least edge_width = 0.051 if you plot curved edges. What is interesting is that straight edges remain visible below edge width 0.051, but they won't look thinner, the width seemingly rounded to probably 1.0. As it can be seen in python igraph's source code, edge.width is passed directly to cairo.Context.set_line_width(). I have seen this latter at many places used with floats below 1.0, probably the result depends on the actual cairo surface.