【问题标题】:How to decimate / decrease number of tic labels in gnuplot matrix如何抽取/减少gnuplot矩阵中的tic标签数量
【发布时间】:2016-12-26 18:11:47
【问题描述】:

我有一个数据矩阵,它是自动音乐转录程序的输出。我想使用 gnuplot 绘制它,并分配适当的标签。 Here's my dropbox with some data,其中 Intensity.dat 是实际数据,example.stn 是一列字符串值,其中一些将显示在 y 轴上,example.all 只是 @987654323 的结果@脚本:

reset
set title "Intensity detection"
set palette negative grayscale
set cbrange [0.01:1]
set xlabel "Time [s]"
set ylabel "Musical note"
set terminal qt font "Verdana,16"
set logscale cb
xincr=0.04644
yincr=1
plot 'example.all' u (($1+0.5)*xincr):($2*yincr):3 matrix with image

产生 plot produced by script 1。一切正常,现在只是 tic 标签...

在我将最后一行更改为 plot 'example.all' u (($1+0.5)*xincr):($2*yincr):3 matrix rowheaders with image 后,y 轴变得过于密集(这是我的保管箱中的 plot2.jpg,链接在顶部。对不起,我是新手它不允许我发布超过 2 个链接)。 我想要的是一种只显示我想要的标签(或隐藏其他标签,无论如何)的方法,而不是一次全部显示(因为它看起来不可读)。我还希望能够在需要时快速将它们更改为其他人。假设,我想每 12 个标签显示一次,但仍保留整个矩阵并绘制所有行。或者从第 2 个标签开始每隔 12 个,从第 6 个标签开始每隔 12 个。我已经尝试了很多方法,但我被卡住了。像 :ytics() 或 :yticlabels() 这样的函数做不到,至少对我来说是这样。是的,我需要这个 Verdana 16,完全删除标签是不可能的。

如果该方法也适用于 x 轴,我将不胜感激,因为我在其他情节中遇到 x 轴的类比问题,但我通常感谢任何帮助。

【问题讨论】:

    标签: matrix text gnuplot axis-labels


    【解决方案1】:

    您可以像这样将绘制图像与绘制 ytics 分开:

    condition(n) = (ceil(n)%12-2 == 0) || (ceil(n)%12-6 == 0)
    
    plot 'Intensity.dat' u (($1+0.5)*xincr):($2*yincr):3 matrix with image ,\
         'example.stn' u (NaN):0:ytic(condition($0) ? strcol(1) : "")  notitle
    

    函数condition 检查是否应该绘制标签。我使用ceil 将实数转换为模运算符 (%) 所需的整数。 condition 函数使用行号$0 调用。 NaN while plotting 'example.stn' 避免绘制数据点,同时保留设置标签的机会。如果满足条件(从第 2 个开始的第 12 个标签或从第 6 个开始的第 12 个标签),我们使用实际标签,否则使用空字符串。

    【讨论】:

    • 首先,感谢您的快速回复,我相信这是解决方案。对于任何寻找 x 轴标签的人,它是 condition(n) = (ceil(n)%12-2 == 0) || (ceil(n)%12-6 == 0) 和绘图部分 plot 'example.dat' u (($1)*xincr):($2*yincr):3 matrix with image ,\ 'example.stn' u 0:(NaN):xtic(condition($0) ? strcol(1) : "") notitle
    猜你喜欢
    • 1970-01-01
    • 2017-10-04
    • 1970-01-01
    • 2021-10-22
    • 2018-03-07
    • 1970-01-01
    • 2015-10-25
    • 2020-07-13
    • 1970-01-01
    相关资源
    最近更新 更多