[英]gnuplot plot labelled data
I am new to gnuplot and am having trouble finding the meaning of some of the commands. 我是gnuplot的新手,我很难找到一些命令的含义。 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.
我想绘制一个csv文件,其中行是数据点,三列分别代表数据标签,x值和y值。 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.
我希望x轴上的第二列和y轴上的第三列以及第一列作为附加到该点的标签。 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
I have tried things like 我尝试过类似的东西
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"
Part of your confusion is probably gnuplot's shorthand notation for a lot of things. 你的困惑的一部分可能是gnuplot的很多东西的简写符号。 For example, in the command above,
u
stands for using
and w
stands for with
and tc
stands for textcolor
. 例如,在上面的命令中,
u
代表using
, w
代表with
, tc
代表textcolor
。 In general, gnuplot allows you to shorten a command to the shortest unique sequence of characters that can be used to identify it. 通常,gnuplot允许您将命令缩短为可用于识别它的最短唯一字符序列。 so
with
can be w
, wi
, wit
and gnuplot will recognize any of them since no other plot specifiers start with w
. 所以
with
可能是w
, wi
, wit
和gnuplot的将识别任何人,因为没有其他的情节与符开始w
。
The numbers after the using specifier are columns in your datafile. using指示符后面的数字是数据文件中的列。 So here, the x position of the label is taken from the 2nd column.
所以这里,标签的x位置取自第2列。 The y position is taken from the 3rd column.
y位置取自第3列。 And the label text is taken from the 1st column which is where we get the
using 2:3:1
. 标签文本取自第1列,即我们
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. 它实际上比它更强大(语法将允许你一起添加2列以获得x或y位置),但解释所有这些应该留给另一个问题。
Since you are using a csv file you should set the separator: 由于您使用的是csv文件,因此应设置分隔符:
set datafile separator ','
Also, I think this is what you're trying to do: 另外,我认为这是你要做的事情:
plot 'infile' using 2:3, 'infile' 2:3:1 with labels offset 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.