我有多个 gnuplot 文件来生成相同的图表,但在不同的时间范围内。所以我有一个可以渲染所有内容,一个只渲染最后 48 小时,一个渲染特定月份。
我现在的问题是,有没有办法重用大多数设置(因为它们大多相同)并且只更改绘图范围和输出文件的值?
例如,这些是 48 小时设置:
set xlabel "Date (UTC)"
set ylabel "Size (Gibibytes)"
set title sprintf("Storagespace used and available (Generated: %s)", date)
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
set format x "%Y\n%m-%d\n%H:%M"
set xtics rotate
set terminal svg size 1280,720
set output "/var/www/sizes/sizes-graph-48h.svg"
set datafile separator " "
set autoscale xfix
set key below
set grid xtics ytics
FACTOR=1024*1024
plot "< tail -48 /home/fabian/sizes" using 1:($3/FACTOR) title 'Used by 4th/Aufnahme' with lines lc rgb "#008080", \
"" using 1:($2/FACTOR) title 'Used by 3rd/Aufnahme' with lines lc rgb "#65000B", \
"" using 1:($5/FACTOR) title 'Available on 4th' with lines lc rgb "blue", \
"" using 1:($4/FACTOR) title 'Available on 3rd' with lines lc rgb "red", \
"" using 1:(($5+$3*17/20)/FACTOR) title 'Est. max. available on 4th' with lines lc rgb "#0F52BA", \
"" using 1:(($4+$2*17/20)/FACTOR) title 'Est. max. available on 3th' with lines lc rgb "#E62020", \
20 notitle
这是 48 小时设置和特定月份设置之间的差异:
9c9
< set output "/var/www/sizes/sizes-graph-48h.svg"
---
> set output sprintf("/var/www/sizes/sizes-graph-%s.svg", month)
15c15
< plot "< tail -48 /home/fabian/sizes" using 1:($3/FACTOR) title 'Used by 4th/Aufnahme' with lines lc rgb "#008080", \
---
> plot sprintf("< grep \"%s*\" /home/fabian/sizes", month) using 1:($3/FACTOR) title 'Used by 4th/Aufnahme' with lines lc rgb "#008080", \
如您所见,除了输出文件(可以设置month
为48h
)和绘图范围参数外,它们是相同的。要完整,这里是 48 小时设置与“整体”设置的差异:
9c9
< set output "/var/www/sizes/sizes-graph-48h.svg"
---
> set output "/var/www/sizes/sizes-graph.svg"
15c15
< plot "< tail -48 /home/fabian/sizes" using 1:($3/FACTOR) title 'Used by 4th/Aufnahme' with lines lc rgb "#008080", \
---
> plot "/home/fabian/sizes" using 1:($3/FACTOR) title 'Used by 4th/Aufnahme' with lines lc rgb "#008080", \
好的,这里的输出文件最后没有破折号,但我可以使用类似set output sprintf("/var/www/sizes/sizes-graph%s.svg", range)
where range
is like month
before 但带有前导破折号的东西。
但主要问题是:一旦我使用 tail,在另一种情况下我使用 grep,在最后一种情况下我都不使用(尽管我可以使用匹配所有行的 grep)。那么有没有办法说类似的话gnuplot settings.gnuplot plotsource="< tail -48 /home/fabian/sizes"
?
费边