由xy-coordinaten分类
我想绘制所有位于圆上的gnuplot结果。对于每个值,我都有相应的XY坐标和相应的ID号(总共4列),但按顺序取决于顺序。将排序的排序以使旋转方向来自-x => -y => +x => +y,在-x上再次结束。因此,圆的中心在0。如何用“排序”(或使用“ awk”?)命令(使用Linux)实现此问题?
根据Theozh的建议,我将更加精确地提出我的问题。 想象一下,一个小点作为微小符号的时钟表盘。分钟点的位置可以由极坐标或笛卡尔坐标确定。我的文件包含具有关联值的笛卡尔坐标(结果)。该文件包含60行带有X -y坐标,并在第三列中的结果。当然,根据象限,X和Y的迹象。不幸的是,这些线的分类不是以与循环感相对应的方式进行排序。因此,“分钟30”点的线不在第30行,例如第17行。任务是按坐标对行进行排序,以便它们以1到60的顺序出现。然后将简单地定义1到60,然后y轴将包含结果(从第三列)
I want to plot results in gnuplot that all lie on a circle. For each value I have the corresponding x-y coordinates and a corresponding ID number (so 4 columns in total), but in an unsorted order. The rows are to be sorted in such a way that the direction of rotation is from -x => -y => +x => +y and end again at -x. So the center of the circle is at 0. How to implement this with "sort" (or alternatively with "awk"?) command (using Linux)?
At Theozh's suggestion, I will formulate my problem a little more precisely.
Imagine the dial of a clock with small dots as minute symbols. The position of the minute points can be determined by polar coordinates or by Cartesian coordinates. My file contains the Cartesian coordinates with an associated value (result). The file contains 60 lines with x - y coordinates and the result in the third column. Depending on the quadrant, the signs of x and y change, of course. Unfortunately, the lines are NOT sorted in such a way that they correspond to the sense of circulation. So the line for the point "minute 30" is not in line 30, but e.g. in line 17. The task is to sort the lines by the coordinates so that they appear in the order from 1 to 60. In the diagram, the x-axis would then simply be defined from 1 to 60 and the y-axis would then contain the results (from the 3rd column)
My unsorted file (coordinates for a unit circle, result values simplified for a better overview)
And this is what I want to have (8 rows (every 45°) sorted counterclockwise):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用AtAN2()函数直接从X/Y坐标计算角度。
您不会确切地说要绘制的是什么。如果仅仅是点本身(文件中的每个行),则可以在gnuplot内部轻松完成。我显示了GNUPLOT 5.5的输出。在较早的版本中,并且取决于您要绘制的内容,它可能需要其他命令来在单独的步骤中对数据进行排序,然后绘制排序的数据。如果您澄清该策略的确切要素,我将相应地修改示例。
示例与随机x和y坐标使用100点:
更新的答案
修订了以显示样本数据的图
,实际上,如果您不在乎什么顺序这些点才得出,只有在结束的地方,命令才更简单,因为没有必要排序!
The angle can be calculated directly from the x/y coordinates using the atan2() function.
You do not say exactly what it is that you want to plot. If it is simply the points themselves (one point per line in the file), then this can be done easily inside gnuplot. I show the output from gnuplot 5.5. In earlier versions, and depending on exactly what you want to plot, it might require additional commands to sort the data in a separate step and then plot the sorted data. If you clarify what exactly is supposed to go into the plot, I will modify the example accordingly.
Example using 100 points with random x and y coordinates:
Updated answer
Revised to show a plot of the sample data as given
And actually, if you don't care what order the points are drawn in, only where they end up, the command is even simpler because there is no need to sort!