如何绘制来自不同文件的直方图和常量线

How to plot an histogram and a constant line from different files

我是 gnuplot 的新手,我有一个问题:

我有 2 个不同的文本文件,第一个 (file1.txt) 是这样的:

Switch,Port,BPS
S1,1,5464091.33
S1,3,5465677.33
S2,2,5463298.00
S2,3,5462729.67
S3,1,5461340.67
S3,3,5461772.33

然后我用直方图绘制 "file1.txt":

plot avg_file using 3:xticlabels(stringcolumn(1)."-".stringcolumn(2)) title columnheader

这很好用。

现在我有 file2.txt,其中包含一个值:

AVG_BPS
4844714.81

我想将该值绘制为上一个图形(直方图)上的恒定水平线。

这是我的完整脚本:

# Terminal definition (PNG image)
set term png

# Settings
set datafile separator ","
set output 'myplot.png'
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 1

# Graph and Axis titles
set title  "BPS"
set xlabel "Switch-Port"
set ylabel "bits-per-second"

# Plot
plot "file1.txt" using 3:xticlabels(stringcolumn(1)."-".stringcolumn(2)) title columnheader

这是myplot.png

谢谢

可能最好的办法是 stats:

stats 'file2.txt' u 1
hor_value=STATS_min

然后添加到您的情节中:

plot "file1.txt" using 3:xticlabels(stringcolumn(1)."-".stringcolumn(2)) title columnheader, hor_value 

或者在上面放一行(在最后一个图之前):

set arrow nohead from graph 0, hor_value to graph 1, hor_value front