Gnuplot 如何使拟合函数的线条颜色随y变化?
所以,如果我有一组数据,比如说“GnuTest.dat”,我将f(x)=a*x**2拟合到它,然后把它们都画出来,有没有办法让f(x)的颜色随f(x)而变化 这就是我目前的情况:Gnuplot 如何使拟合函数的线条颜色随y变化?,gnuplot,Gnuplot,所以,如果我有一组数据,比如说“GnuTest.dat”,我将f(x)=a*x**2拟合到它,然后把它们都画出来,有没有办法让f(x)的颜色随f(x)而变化 这就是我目前的情况: set autoscale set term aqua size 700,500 set palette positive nops_allcF maxcolors 1 gamma 1.5 color model HSV set palette defined ( 0 0 1 1 , 1 1 1 1 ) unset l
set autoscale
set term aqua size 700,500
set palette positive nops_allcF maxcolors 1 gamma 1.5 color model HSV
set palette defined ( 0 0 1 1 , 1 1 1 1 )
unset log
set termoption enhanced
set xtics 1
set mxtics 4
set ytics 1
set mytics 4
set title "Gnuplot Script Template"
set xlabel "x"
set ylabel "y"
set size ratio -1
a = 1
b=0.5
f(x) = a*x**2 +b
stats "GnuTest.rtf" u 1:2
print STATS_max_y;
fit f(x) "GnuTest.rtf" using 1:2 via a,b
plot "GnuTest.rtf" using 1:2 title "Gnu Test" w points pt 7, f(x) t "ax^2 + b fit" w lines lc variable
所以在理论上,我想在最小和最大的f(x)值之间沿色调比例改变颜色。我试过在之后使用1:2放置:(f(x)/STATS\u max\u y)
或类似的东西,但我总是会遇到诸如“x未定义”或“预期”之类的错误。我错过了什么明显的东西吗
编辑:按照@Christoph的建议,我的情节就是这样的。我有set term选项solid
并使用了lt-1
要在函数中使用可变linecolor,必须使用'+'
特殊文件名。这允许您使用使用
选项,该选项是与可变linecolor一起使用所必需的。请注意,这与安装完全无关
下面是一个最小的可运行脚本:
set palette defined ( 0 0 1 1 , 1 1 1 1 ) color model HSV gamma 1.5
set xrange[0:10]
f(x) = x**2
plot '+' using 1:(f($1)):(f($1)) with lines linecolor palette lw 3 notitle
4.6.3的结果是:
请注意,您不能使用maxcolors 1
,因为这样(至少对我来说)只会产生黑色。谢谢,解决了我问题的主要部分(因此被接受)。然而,在我的终端(aquaterm
)中,无论我对linetype
做了多少修改,我都只能得到一条虚线maxcolors
应该是0,这只是我在尝试找到自己的解决方案时所玩的东西之一!我从来没有用过aquaterm,所以这是一种猜测。您应该只能使用带有set term选项solid
的实线。此外,线型-1应始终为实心。相关: