在同一图像中包含多组数据或函数时,图例是必要的。我们这一次谈一谈图例的微调。 这次来画前 3 阶的第一类贝塞尔函数 Jn(x)。在 gnuplot 里,0 阶和 1 阶贝塞尔函数已经定义了,分别为 besj0(x) 和besj1(x),而 2 阶贝塞尔函数可以通过递推关系构造出来。下面是例子: gnuplot> set term wxt enhanced gnuplot> besj2(x) = besj1(x)*2/x - besj0(x) gnuplot> set xrange [0:20] gnuplot> set xtics 2 gnuplot> set xlabel "X" gnuplot> set ylabel "Y" gnuplot> set title "Bessel Functions of the First Kind" gnuplot> set grid gnuplot> set style line 1 lw 2 lc rgb "#F62217" gnuplot> set style line 2 lw 2 lc rgb "#D4A017" gnuplot> set style line 3 lw 2 lc rgb "#2B60DE" gnuplot> plot besj0(x) ls 1 t "J_0(x)", besj1(x) ls 2 t "J_1(x)", besj2(x) ls 3 t "J_2(x)" 之前我们讲过,plot 命令后面可以跟随一些参数(例如 linewidth, linecolor 等)来改变点线风格。在上面的例子中,我们把这些参数单独拿出来放到了 set style 命令里,定义了三个 linestyle,然后在 plot 命令里再调用这些linestyle。这样子做和我们之前的做法效果上没什么不同,唯一的区别是让 plot 命令短了一些。另外,改变风格可能容易一点。 上面是默认的图例,下面让我们进行微调。
|
|
来自: icewater1234 > 《gnuplot》