Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 使用Gnuplot在组中显示Y标签_Linux_Bash_Charts_Plot_Gnuplot - Fatal编程技术网

Linux 使用Gnuplot在组中显示Y标签

Linux 使用Gnuplot在组中显示Y标签,linux,bash,charts,plot,gnuplot,Linux,Bash,Charts,Plot,Gnuplot,我有以下几点: 0.00049 1.509 0.00098 1.510 0.00195 1.511 0.00293 1.509 0.00391 1.510 0.00586 1.523 0.00781 1.512 0.01172 1.514 0.01562 1.510 0.02344 1.511 0.03125 1.510 0.04688 7.053 0.06250 7.054 0.09375 7.187 0.125 7.184 0.1875 7.177 0.25 7.207 0.375 16.5

我有以下几点:

0.00049 1.509
0.00098 1.510
0.00195 1.511
0.00293 1.509
0.00391 1.510
0.00586 1.523
0.00781 1.512
0.01172 1.514
0.01562 1.510
0.02344 1.511
0.03125 1.510
0.04688 7.053
0.06250 7.054
0.09375 7.187
0.125 7.184
0.1875 7.177
0.25 7.207
0.375 16.588
0.5 24.930
0.75 39.394
1 56.615
1.5 77.308
2 84.909
3 89.056
4 88.485
6 88.678
8 89.022
12 88.513
16 88.369
24 88.512
32 88.536
48 87.792
64 87.716
96 87.589
128 87.608
192 87.457
256 87.388
这个gnuplot脚本:

#! /usr/bin/gnuplot

set terminal png
set output "lat_mem_rd.png"
set title "Memory Latency Benchmark (Stride 512)"

set xlabel "Memory Depth (MB)"
set ylabel "Latency (ns)"
set xtics rotate by 45 offset 0,-1
set xtics font "Times-Roman, 8"

set grid

set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1   # --- blue

plot "lat_mem_rd.dat" using (log($1)):2:xtic(1) smooth unique title "" with linespoints ls 1
这将生成此图形:

但是我想用这些近似值中的一个近似值来显示y标签中的y值,例如,对于x值在3到256之间的所有值,y标签只设置为一个,可能是88.513,对应于x=12或其他(或者可能是这些点的平均值,如果不是很难)

对于介于0和0.02344之间的x值以及介于0.03125和0.1875之间的x值,情况相同


此y值将替换值10、20、…、90。

这里是对脚本的修改,如果我理解正确,它可能会执行您想要的操作:

set title "Memory Latency Benchmark (Stride 512)"

set xlabel "Memory Depth (MB)"
set ylabel "Latency (ns)"
set xtics rotate by 45 offset 0,-1
set xtics font "Times-Roman, 8"

set grid

a = ""; p = 0; nn = 1; nt = 37; d = 4; s = 0

f(x) = (x>p+d || nn >= nt)?(nn=nn+1, p=x, a=a." ".sprintf("%5.2f", s/n), n=1, s=x):(nn=nn+1, p=x, s=s+x, n=n+1)

plot "lat_mem_rd.dat" using 1:(f($2)) # Just to set array "a"

set ytics 0,0,0

set yrange [0:90]

set for [aa in a] ytics add (aa aa)

set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1   # --- blue

set terminal png
set output "lat_mem_rd.png" 

plot "lat_mem_rd.dat" using (log($1)):2:xtic(1) smooth unique title "" with linespoints ls 1
此脚本生成以下绘图:

该策略是累积Y值之和,并且每当Y值增加至少一个量d时计算平均值;这些平均值存储在一个字符串变量“a”中,该变量在最后一个plot命令之前循环设置数值。这样,紧密间隔的Y值簇在其平均值处产生一个值;我想这正是你想要的。

也许这能帮你。当然,您必须对Y轴执行等效操作,并可能停用“正常”Y记号。