我已数据集(文件名“数据”)是这样的:
a 10.1
b 10.1
c 10.2
b 15.56
a 3.20
,我希望绘制该数据为点。当我尝试:
plot 'data' using 2:xticlabels(1)
我得到了5个x轴值a,b,c,b,a的情节,但我只想得到3个(a,b,c(顺序不重要))的情节与所有5 y值。可能吗?gnuplot的,非数字重复x值
我真正的数据文件看起来像这样:
2-8-16-17-18 962.623408
2-3-4-5-6 -97.527840
2-8-9-10-11 962.623408
2-8-9-10-11 937.101308
2-3-4-5-6 37.101308
,拥有大约一千记录。
我不知道如何使用mgilson的代码,但他给了我一个主意。我添加到数据文件附加列(索引):
1 a 10.1
2 b 10.1
3 c 10.2
2 b 15.56
1 a 3.20
之后,在gnuplot的ploting很简单:
plot 'data' u 1:3
我用perl的,所以我的脚本lookls这样的:
#!/usr/bin/perl
$index_number = 0;
while (<>)
{
$line = $_;
@columns = split(" ",$line);
$col1 = $columns[0];
$col2 = $columns[1];
if(not exists $non_numeric{$col1})
{
$index_number++;
$non_numeric{$col1} = $index_number;
}
print "".$non_numeric{$col1}."\t".$col1."\t".$col2."\n";
}
x轴上的顺序实际上是否重要? – mgilson