Gnuplot不同的颜色
我正在尝试用不同的颜色为gnuplot中的一个绘图和一个fit着色,但它不起作用:Gnuplot不同的颜色,gnuplot,Gnuplot,我正在尝试用不同的颜色为gnuplot中的一个绘图和一个fit着色,但它不起作用: set ylabel "s in m" set xlabel "t in s" unset key set style line 1 lt 2 lc rgb "red" lw 3 set style line 2 lt 2 lc rgb "orange" lw 2 plot "-" with lines ls1 0 0 1 4.2 2 7.9 3 11.7 4 16.3 fit "-" with lines ls
set ylabel "s in m"
set xlabel "t in s"
unset key
set style line 1 lt 2 lc rgb "red" lw 3
set style line 2 lt 2 lc rgb "orange" lw 2
plot "-" with lines ls1
0 0
1 4.2
2 7.9
3 11.7
4 16.3
fit "-" with lines ls2
0 0
1 4.2
2 7.9
3 11.7
4 16.3
有人知道我做错了什么吗?有几件事你做错了:
fit
命令与plot
命令稍有不同。您必须定义一个函数,如f(x)=a*x+b
,并使其适合您的数据。这将为a
和b
计算适当的值。之后,您可以绘制函数e
终止内联数据ls 1
(数字前有空格)set ylabel "s in m"
set xlabel "t in s"
unset key
set style line 1 lt 2 lc rgb "red" lw 3
set style line 2 lt 2 lc rgb "orange" lw 2
f(x) = a*x + b
fit f(x) '-' via a,b
0 0
1 4.2
2 7.9
3 11.7
4 16.3
e
plot f(x) with lines ls 2, "-" with points ls 1
0 0
1 4.2
2 7.9
3 11.7
4 16.3
e
这会将您的拟合绘制为直线,并将相应的数据绘制为点。谢谢!从这个答案中学到了很多东西!:)