gnuplot中xticlabels中的自定义字符串 [英] Custom string in xticlabels in gnuplot

查看:178
本文介绍了gnuplot中xticlabels中的自定义字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此线程在这里: xticlabels中的自定义字符串

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

solved the question of customizing xticlabel strings.

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

Now, how do I sort the data from column 4 (for example) so that only rows containing certain strings in column 4 will be used to create the xticlabel? IOW, what is the proper format to do: (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

我们可以用这条线来绘制它:

we can plot it with this line:

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

它创建了这个图:

基本上我所做的是查看第1列中的字符串,如果它是"Sunrise",则将其与第2列中的字符串连接起来.如果不是"Sunrise",则返回一个空字符串以防止将标签放置在此处.但是,这确实会在每个数据点的位置放置一个主要的抽号.为避免这种情况,可以使用以下命令:

Basically what I did there is I looked at the string in column 1, if it is "Sunrise", I concatenated it with the string in column 2. If it isn't "Sunrise", then I return an empty string to prevent a label from being placed there. This does however, place a major tic at the location of each data point. To avoid that, you can use the following:

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

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

which produces this plot (I've tested on gnuplot 4.4.2 and 4.6.0):

它还会发出一些有关非字符串标签的警告,但我想这是可以的.

It also issues a bunch of warnings about non-string labels, but I guess that's OK.

这篇关于gnuplot中xticlabels中的自定义字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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