在绘图之前,您需要知道数量级。你可以通过stats
得到这个。然后将y值除以选择的因子(在下面的示例中),使得轴tics应显示0到100之间的值。
代码:
### automatic prefactor in axis scaling and axis label
reset session
# generate some random data
set samples 20
RandomMagnitude = floor(rand(0)*20-10)
RandomValue = rand(0)
set table $Data
plot '+' u 0:(RandomValue*10**RandomMagnitude/($0)) with table
unset table
# get the maximum via stats
stats $Data u 2 nooutput
Max = STATS_max
PrefactorLog = ceil(log10(Max))-2
Prefactor = 10**PrefactorLog
set ylabel sprintf("Y-title, x 10^{%d} units",PrefactorLog)
set format y "%g"
set boxwidth 0.7 relative
plot $Data u 1:($2/Prefactor) with boxes fs solid 1.0 fc rgb "red" ti sprintf("Max value %.2e", Max)
### end of code
结果: