加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 使用Gnuplot在组中显示Y Label

发布时间:2020-12-14 01:36:58 所属栏目:Linux 来源:网络整理
导读:我有这一点: 0.00049 1.5090.00098 1.5100.00195 1.5110.00293 1.5090.00391 1.5100.00586 1.5230.00781 1.5120.01172 1.5140.01562 1.5100.02344 1.5110.03125 1.5100.04688 7.0530.06250 7.0540.09375 7.1870.125 7.1840.1875 7.1770.25 7.2070.375 16.58
我有这一点:

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或其他(或者如果不是很困难,可能是那些点的平均值)……

x值介于0和0.02344之间,x值介于0.03125和0.1875之间.

该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,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,s=s+x,n=n+1)

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

set ytics 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”中,该字符串变量循环以在最终绘图命令之前设置ytic值.这样,紧密间隔的Y值群就会产生平均值;我想这就是你想要的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读