graph - 如何在 gnuplot 上绘制树/图/网络数据?

标签 graph plot tree gnuplot nodes

我有一个由边缘和颜色组成的数据集,我想以类似网络的方式绘制它们,使用线条和圆圈(如下图所示),并可能使用簇着色。

Graph example

数据的组织方式如下:

point1a_x point1a_y color
point1b_x point1b_y color

point2a_x point2a_y color
point2b_x point2b_y color
(...)

point2n_x point2n_y color
point2n_x point2n_y color

我将如何在 gnuplot 上进行此操作?

最佳答案

好的,所以我自己解决了这个问题,我将在这里留下详细信息,以帮助有相同问题的人。

节点上带有标签的单色图:

这将生成一个与问题中的图表非常相似的图表,其中有连接圆圈和内部标签的线。

Single color graph with labels on the nodes

plot 'edges.dat' u 1:2 with lines lc rgb "black" lw 2 notitle,\
'edges.dat' u 1:2:(0.6) with circles fill solid lc rgb "black" notitle,\
'edges.dat' using 1:2:($0) with labels tc rgb "white" offset (0,0) font 'Arial Bold' notitle

只需稍加改动,它就可以与问题图片上的完全匹配。

enter image description here

plot 'edges.dat' u 1:2 with lines lc rgb "black" lw 2 notitle,\
'edges.dat' u 1:2:(0.8) with circles linecolor rgb "white" lw 2 fill solid border lc lt 0 notitle, \
'edges.dat' using 1:2:($0) with labels offset (0,0) font 'Arial Bold' notitle
<小时/>

簇色图:

Cluster-colored graph

unset colorbox

set palette model RGB defined ( 0 0 0 0 , 1 1 0 0 , 2 1 0.9 0, 3 0 1 0, 4 0 1 1 , 5 0 0 1 , 6 1 0 1 )

plot 'edges.dat' u 1:2:3 with lines lc palette notitle,\
'edges.dat' u 1:2:(0.15):3 with circles fill solid palette notitle
<小时/>

所有图中使用的数据都遵循以下结构:

21.53 9.55 0
24.26 7.92 0

5.63 3.23 1
2.65 1.77 1

5.63 3.23 0
4.27 7.04 0

(...)

关于graph - 如何在 gnuplot 上绘制树/图/网络数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20406346/

相关文章:

python - 是否有与 Borland C 命令 putpixel 等效的 Matplotlib?

python matplotlib 以小时格式设置 xticks

算法 - 查找树中具有直径距离的对数?

c++ - 使用 Boost Graph Library (BGL) 识别连通分量

algorithm - 查找所需的最小数量 'central points'

python - 使用 pandasplot() 时出现意外振荡

python - 将目录树表示为 JSON

javascript - FuelUX 树数据源无法正常工作?

r - 在图论中解释社区结构

r - scale_x_date (ggplot) 中的限制参数仍然产生 data.frame 范围之外的日期