如何在gnuplot上绘制树/图/网页数据? [英] How to plot tree/graph/web data on gnuplot?

查看:142
本文介绍了如何在gnuplot上绘制树/图/网页数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

b
$ b



数据组织如下:

  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上做这件事?

解决方案

接受回答对我来说并不完美。以下是我如何改变它:



输入文件的格式



 #一个顶点有三个字段:x坐标,y坐标和标签
#一条边由连续行中的两个点组成
#每条边之间必须有一条或多条空行。

21.53 9.55 a
24.26 7.92 B

5.63 3.23 C
2.65 1.77 D

5.63 3.23 C
4.27 7.04 E

#...

另一个答案是标签属于顶点,而不是边缘。



另外请注意,我将标签更改为字母而不是数字。标签可以是任何字符串,这使得它更清晰,它们不是示例中的顺序索引。



绘图命令



  plot \ 
'edges.dat'使用1:2与行lc rgbblacklw 2 notitle,\
'edges.dat'使用1:2:(0.6),用圆圈填充solid lc rgbblacknotitle,\
'edges.dat'使用带标签的1:2:3 tc rgbwhiteoffset(0,0)字体'Arial Bold'notitle

这里的大变化是现在绘制标签时我们绘制第三个字段 $ 0 字段,这是一个连续号码。


I have a data-set that consist of edges and colors, and I want to plot them on a web-like manner, with lines and circles such as the picture below, and possibly with cluster coloring.

The data is organized like this:

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

How would I go about doing it on gnuplot?

解决方案

The accepted answer didn't quite work out for me. Here is how I had to change it:

The format of the input file

# A vertex has 3 fields: x coordinate, y coordnate and the label
# An edge consists of two points in consecutive lines
# There must be one or more blank lines between each edge.

21.53 9.55 A
24.26 7.92 B

5.63 3.23 C
2.65 1.77 D

5.63 3.23 C
4.27 7.04 E

#...

The big difference compared to the other answer is that the labels belong to vertices, not edges.

Also note that I changed the labels to letters instead of numbers. Labels can be any string and this makes it clearer that they are not sequential indexes in the example.

The plotting command

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

Big change here is that now when plotting the labels we plot the 3rd field instead of the $0 field, which is a sequential number.

这篇关于如何在gnuplot上绘制树/图/网页数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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