【问题标题】:Gnuplot format converting, bytesGnuplot 格式转换,字节
【发布时间】:2016-12-15 09:45:46
【问题描述】:

例如,我有大量字节,其中一些等于千兆字节。

当前的格式化设置set format y "%.2s%cb 这样做:

1.20G
1.00G
800.00M
600.00M
.....
0

我需要将 ytics 转换为仅显示三位数字,或/并且主要以一种科学力量显示:

1.00G
0.80G
0.60G
....
0

我该怎么做?

【问题讨论】:

    标签: format gnuplot format-specifiers


    【解决方案1】:

    那么你不能使用 gnuplot 的自动格式化。如果您知道数据必须以千兆字节为单位显示,请使用

    set format y "%.2fG"
    plot 'data.dat' using 1:($2/1e9)
    

    这假设第二列中的数据以字节为单位。

    如果要坚持最大科学力,可以先用stats确定最大值,然后计算科学力:

    stats 'data.dat' using 2 nooutput
    scientific_power_index = ceil(log10(STATS_max)/3)
    scientific_power = word("'' k M G T", scientific_power_index)
    scale = 10**((scientific_power_index - 1) * -3)
    
    set format y "%.2f".scientific_power
    plot 'data.dat' using 1:($2 * scale)
    

    请注意,这仅适用于 gnuplot 5,如果最大 y 值与自动缩放的最大 y 值具有不同的科学功效,则它无法正常工作(例如最大值 990e6 -> 自动缩放需要 1e9 ,但上面的代码仍将'M'作为科学力量)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-09
      • 2018-10-03
      • 2012-11-27
      • 2017-02-24
      • 2022-07-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-12
      相关资源
      最近更新 更多