gpt4 book ai didi

Gnuplot 直方图 x logscale

转载 作者:行者123 更新时间:2023-12-01 01:00:07 26 4
gpt4 key购买 nike

我在 bash 脚本中使用 gnuplot 来绘制一些东西。
对于这个特殊图形,我需要以矩阵大小为 x 轴打印矩阵的数量(y 轴)。
由于分布可能非常稀疏,我想对 x 和 y 使用对数刻度。它适用于 y,但 gnuplot 告诉我,当我使用直方图样式时,我无法为 x 轴设置对数刻度。

任何想法来调试这个?或者如何使用类似的方式呈现结果?

set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set logscale xy
plot '$res/histo-$ld-$lr-$e-$r' using 2:xtic(1) title 'Run'

错误是:
line 0: Log scale on X is incompatible with histogram plots

提前致谢。

编辑:顺便说一句,我使用的是 gnuplot 4.4 patchlevel 4 并且刚刚更新到最新版本(即 4.6 patchlevel 5)

最佳答案

Gnuplot 直方图的工作方式与您的想法略有不同。 x 轴不是数字。在您的情况下,第一行第二列中的值放置在 x 值为 0 处,y 值取自第二列,手动标签取自第一列第一行。第二行的值放置在 x=1 等处。

您可以尝试使用框绘图样式,该样式与“常规”x 轴一起使用并支持 x 中的对数刻度:

set logscale xy
set offset 0,0,1,1
set boxwidth 0.9 relative
set style fill solid noborder
plot 'data.dat' with boxes

带数据文件 data.dat
1 1000
2 300
5 150
20 10
135 3

这给出了结果(4.6.5):

enter image description here

为了有一个固定的 boxwidth 和一个变化的 box 距离,你可以使用第三列来指定一个 box 宽度作为 x 值的百分比:
set logscale xy
set offset 0,0,1,1
set style fill solid noborder
plot 'data.dat' using 1:2:($1*0.5) with boxes

enter image description here

将实际值放在 x 轴上的工作方式如下:
set logscale xy
set offset 0,0,1,1
set style fill solid noborder
plot 'data.dat' using 1:2:($1*0.5):xtic(1) with boxes

enter image description here

关于Gnuplot 直方图 x logscale,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24207850/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com