gnuplot 绘制标记数据 [英] gnuplot plot labelled data

查看:30
本文介绍了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.

推荐答案

您可以使用以下命令:

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

您的部分困惑可能是 gnuplot 对很多事情的简写符号.例如,在上面的命令中,u 代表 usingw 代表 withtc 代表 textcolor.通常,gnuplot 允许您将命令缩短为可用于识别它的最短的唯一字符序列.所以 with 可以是 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.

using 说明符后的数字是数据文件中的列.所以在这里,标签的 x 位置取自第 2 列.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 绘制标记数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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