gnuplot - gnuplot 中 xticlabels 中的自定义字符串

标签 gnuplot

这个帖子在这里: Custom string in xticlabels

解决了自定义xticlabel字符串的问题。

现在,如何对第 4 列中的数据进行排序(例如),以便仅使用第 4 列中包含某些字符串的行来创建 xticlabel? IOW,正确的格式是什么: (IF strcol(4) eq "Sunrise")plot 'datafile' u 4:2:( xticlabels( strcol(4).strcol(2) ) )

最佳答案

给定此数据文件:

Sunrise cat 1
Sunset dog 2
Sunrise fish 3
waste space 4
blah blah 5
Sunrise label 6

我们可以用这一行来绘制它:

plot 'test.dat' u 3:xticlabels(strcol(1) eq 'Sunrise'?strcol(1).strcol(2):'')

它创建了这个情节:

enter image description here

基本上我所做的就是查看第 1 列中的字符串,如果它是“Sunrise”,我将它与第 2 列中的字符串连接起来。如果它不是“Sunrise”,那么我返回一个空字符串以防止标签被放置在那里。然而,这确实在每个数据点的位置放置了一个主要抽动。为了避免这种情况,您可以使用以下方法:

plot 'test.dat' u 3:xticlabels(strcol(1) eq 'Sunrise'?strcol(1).strcol(2):NaN)

生成此图(我已经在 gnuplot 4.4.2 和 4.6.0 上进行了测试):

enter image description here

它还会发出一系列有关非字符串标签的警告,但我想这没关系。

关于gnuplot - gnuplot 中 xticlabels 中的自定义字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14950726/

相关文章:

graph - gnuplot:在其他规则的 tic 间隔中插入自定义 xtic 标签

gnuplot - 根据一些整数数据列对图进行分区

gnuplot - 使用 gnuplot 的向量场

gnuplot 用 sprintf 生成绘图命令?

gnuplot - 如何在顶部显示中线

在两个文件之间执行数学运算后绘制来自两个文件的数据

graph - 来自 gnuplot 的专业外观图表

linux - GNU绘图 : Graph CSV

date - 如何在 gnuplot 标题中设置当前日期

gnuplot - 如何从文件中绘制对象(矩形)