本文介绍了gnuplot标记数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是gnuplot的新手,无法找到某些命令的含义。我想绘制一个csv文件,其中行是数据点,三列分别表示数据标签,x值和y值。我想要x轴上的第二列和y轴上的第三列,第一列是附加到该点的标签。这是数据

I am new to gnuplot and am having trouble finding the meaning of some of the commands. I want to plot a csv file where the rows are data points and the three columns represent the data label, x value and y value respectively. I want the second column on the x axis and the third column on the y axis and the first column to be the label attached to that point. Here is the data

ACB,  0.0000000,  0.0000000000
ASW,  1.0919705, -0.0864042502
CDX,  0.0000000,  0.0000000000
CEU, -0.4369415, -0.5184317277
CHB, -0.4686879,  0.7764323199
CHD,  0.0000000,  0.0000000000
CHS, -0.4141749,  0.7482543582
CLM, -0.2559306, -0.2535837629
FIN, -0.5004242, -0.2108050200
GBR, -0.4140216, -0.5132990203
GIH,  0.0000000,  0.0000000000
IBS, -0.4928541, -0.5812216372
JPT, -0.4821734,  0.7263450301
KHV,  0.0000000,  0.0000000000
LWK,  1.4515552, -0.0003996165
MKK,  0.0000000,  0.0000000000
MXL, -0.4019733, -0.0484315198
PEL,  0.0000000,  0.0000000000
PUR, -0.2165559, -0.3173440295
TSI, -0.3956957, -0.4549254002
YRI,  1.5555644, -0.0202297606

我已经尝试过类似

plot 'infile' using 2:2 with labels, 'infile' using 1:2

,但报告 。我真的不知道冒号周围的数字是什么意思,虽然我看到他们无处不在别人的代码。

but it reports "Not enough columns for this style". I don't really know what the numbers around the colons mean, although I see them everywhere in others' code.

推荐答案

您可以使用以下命令执行此操作:

You can do this with the following command:

set datafile sep ','
plot 'test.dat' u 2:3:1 w labels point offset character 0,character 1 tc rgb "blue"

部分混淆可能是gnuplot的很多事情的简写符号。例如,在上面的命令中, u 代表使用和 w 代表与和 tc 代表 textcolor 。一般来说,gnuplot允许您将命令缩短到可用于识别它的最短唯一字符序列。因此与可以是 w , wi , wit 和gnuplot将识别它们,因为没有其他的绘图说明符以 w 开头。

Part of your confusion is probably gnuplot's shorthand notation for a lot of things. For example, in the command above, u stands for using and w stands for with and tc stands for textcolor. In general, gnuplot allows you to shorten a command to the shortest unique sequence of characters that can be used to identify it. so with can be w,wi,wit and gnuplot will recognize any of them since no other plot specifiers start with w.

使用说明符后面的数字是数据文件中的列。所以这里,标签的x位置取自第二列。 y位置取自第3列。标签文本取自第一列,这是我们使用2:3:1 得到的地方。它实际上比那更强大(语法将允许你添加2列在一起来导出x或y位置例如),但解释所有这一切应该留给另一个问题。

The numbers after the using specifier are columns in your datafile. So here, the x position of the label is taken from the 2nd column. The y position is taken from the 3rd column. And the label text is taken from the 1st column which is where we get the using 2:3:1. It's actually a lot more powerful than that (the syntax will allow you to add 2 columns together to derive an x or y position for instance), but explaining all of that should probably be left for another question.

这篇关于gnuplot标记数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:53