gnuplot ytics 表示法,如 Matlab
gnuplot ytics notation like Matlab
我想设置 ytics 符号,就像这个 Matlab 图(图形框上只有一个 x10^-5)whit gnuplot。可能吗?
您当然可以在 gnuplot 中 手动 执行此操作,使用许多终端的 enhanced
选项并设置 label
:
set terminal pngcairo enhanced
set output "out.png"
set tmargin at screen 0.95
set label at graph 0,1.05 left 'x 10^{-5}'
plot x
但请注意,您还必须手动缩放 y 轴,例如在本例中将函数的输出 f(x)
缩放到 1e5 * f(x)
。
如果您使用 latex 终端,那么只需对标签使用 latex 语法:set label ... '$\times 10^{-5}$'
.
如果这对您来说还不够,那么也许其他人会提供更自动化的解决方案。
一个更自动化的解决方案是使用unknown
终端来估计自动缩放的yrange限制,计算数量级,设置比例并重新绘制:
set terminal push
set terminal unknown
scale = 1.0
plot 'data.dat' using 1:(/scale) w lp
set terminal pop
max(x,y) = (x > y ? x : y)
exponent = log10(max(abs(GPVAL_Y_MAX), abs(GPVAL_Y_MIN)))
oom = (ceil(exponent) == exponent ? exponent : ceil(exponent) - 1)
scale = 10**oom
set encoding utf8
set label left at graph 0, graph 1.05 sprintf('✕ 10^{%d}', int(oom)) enhanced
set tmargin 4
replot
我想设置 ytics 符号,就像这个 Matlab 图(图形框上只有一个 x10^-5)whit gnuplot。可能吗?
您当然可以在 gnuplot 中 手动 执行此操作,使用许多终端的 enhanced
选项并设置 label
:
set terminal pngcairo enhanced
set output "out.png"
set tmargin at screen 0.95
set label at graph 0,1.05 left 'x 10^{-5}'
plot x
但请注意,您还必须手动缩放 y 轴,例如在本例中将函数的输出 f(x)
缩放到 1e5 * f(x)
。
如果您使用 latex 终端,那么只需对标签使用 latex 语法:set label ... '$\times 10^{-5}$'
.
如果这对您来说还不够,那么也许其他人会提供更自动化的解决方案。
一个更自动化的解决方案是使用unknown
终端来估计自动缩放的yrange限制,计算数量级,设置比例并重新绘制:
set terminal push
set terminal unknown
scale = 1.0
plot 'data.dat' using 1:(/scale) w lp
set terminal pop
max(x,y) = (x > y ? x : y)
exponent = log10(max(abs(GPVAL_Y_MAX), abs(GPVAL_Y_MIN)))
oom = (ceil(exponent) == exponent ? exponent : ceil(exponent) - 1)
scale = 10**oom
set encoding utf8
set label left at graph 0, graph 1.05 sprintf('✕ 10^{%d}', int(oom)) enhanced
set tmargin 4
replot