使用gnuplot绘制与边链接的点 [英] Plot points linked with edges using gnuplot
问题描述
我有一个使用gnuplot绘制的点(x,y)文件.如果我有另一个文件显示通过边缘将哪个点与另一个点链接(例如,链接到(4,7)的(3.8,6)),是否可以在点之间可视化/绘制该边?
I have a file of points (x, y) that I plot using gnuplot. If I have another file that shows which point is linked with which other point by an edge (e.g. (3.8, 6) linked to (4,7)), is it possible to visualise/plot this edges between points ?
推荐答案
根据数据的组织方式,您可能需要考虑绘制with vectors
.
例如,如果您的数据文件如下所示:
depending on how your data is organized, you may want to look into plotting with vectors
.
For example, if your datafile looks like:
#x1 y1 x2 y2
1 1 3 3
您可以使用以下方法绘制此图:
You can plot this using:
set style arrow 1 nohead
plot "my_arrows.dat" using 1:2:($3-$1):($4-$2) with vectors arrowstyle 1
编辑
假设重复数据文件中的所有点,则可以执行以下操作:
Assuming all the points in your datafile are repeated, you can do the following:
set style arrow 1 nohead
plot "my_arrows.dat" using 1:2:($3-$1):($4-$2) with vectors arrowstyle 1,\
"my_arrows.dat" using 1:2 w points
如果不再重复,则可以执行以下操作:
If they're not repeated, you can do:
set style arrow 1 nohead
plot "my_arrows.dat" using 1:2:($3-$1):($4-$2) with vectors arrowstyle 1,\
"my_arrows.dat" using 1:2 w points ls 1 lc rgb "red" pt 1,\
"my_arrows.dat" using 3:4 w points ls 1 lc rgb "red" pt 1
请注意,您可以使用线型(linecolor
或lc
,pointtype
或pt
,linewidth
或lw
等,使点看起来相同.)
Note that you can play around with the linestyles (linecolor
or lc
, pointtype
or pt
, linewidth
or lw
etc. to make the points appear the same.)
这篇关于使用gnuplot绘制与边链接的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!