gnuplot:从数据绘制多边形 [英] gnuplot: draw polygon from data

查看:85
本文介绍了gnuplot:从数据绘制多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用来自文件的数据绘制多边形?例如,如果我有一个文件,其中包含每个数据点的四点多边形的边缘坐标,我将如何进行?

How can I plot polygons with data coming from a file? For example if I have a file containing coordinates of the edges of a four-point polygon for each data point, how would I proceed?

例如包含

0 0 0 1 1 1 1 0
2 2 2 3 3 3 3 2

应在位置(0.5,0.5)和(2.5,2.5)处绘制两个二次矩形机智中心.

should draw two quadratic rectangular wit center at position (0.5,0.5) and (2.5,2.5).

推荐答案

Gnuplot没有专用于绘制任意四边形的绘制样式.为此,您必须使用其他数据文件格式,例如

Gnuplot doesn't have a dedicated plotting style for plotting arbitrary quadrangles. For that, you must use a different data file format like

0 0
0 1
1 1
1 0
0 0

2 2
2 3
3 3
1 0
0 0

,然后可以简单地使用plot 'file.txt' using 1:2 with lines进行绘制.两部分之间的空线告诉gnuplot不连接矩形.

which you can then simply plot with plot 'file.txt' using 1:2 with lines. The empty line between the two parts tells gnuplot to not connect the rectangles.

如果您不能或不想更改数据文件格式,则可以使用外部工具(如

If you cannot or don't want to change the data file format, you can change the data on-the-fly with an external tool like

plot '< awk ''{print $1,$2,"\n",$3,$4,"\n",$5,$6,"\n",$7,$8,"\n",$1,$2,"\n"}'' rect.txt' with lines

这篇关于gnuplot:从数据绘制多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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