为什么在图形绘制中看不到弯曲的边缘? [英] Why curved edges are invisible in igraph plotting?

查看:90
本文介绍了为什么在图形绘制中看不到弯曲的边缘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用cairo PDF的python igraph绘图中,由 edge_curved = X autocurve = True 设置的弯曲边,边缘在PDF输出中不可见。 PNG相同。箭头和所有其他图形元素都是可见的。将边缘设置为笔直,即可看到它们。这是一个最小的示例:

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)


推荐答案

边缘宽度小于0.051时,弯曲边缘始终不可见。实际上,所有边缘宽度> = 0.051并且< 1.0在PDF上看起来相同,可能将1.0以下的数字四舍五入,将< = 0.05舍入为0.0。在PNG绘图上,此边缘宽度范围存在明显差异。

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.

因此,解决方案是,如果绘制曲线边缘,则至少使用 edge_width = 0.051 。有趣的是,直边缘在边缘宽度0.051以下仍可见,但看起来不会变细,宽度似乎四舍五入为1.0。从python igraph的源代码中可以看出, edge.width 直接传递给 cairo.Context.set_line_width()。我在很多使用浮点数低于1.0的地方都看到了后者,可能结果取决于实际的开罗表面。

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.

这篇关于为什么在图形绘制中看不到弯曲的边缘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆