首页 > 解决方案 > 无法在 gnuplot 中绘制直线而不显示不同的点类型

问题描述

我正在使用 gnuplot 绘制一个图形,但该图不断给我不同的点类型而不是直线。我想只使用直线绘制它们,但不断得到 x 或加号或不同的符号。这是我对 gnuplot 脚本的内容。

set terminal pdf
set output "temperatures.pdf"
set style line 1 lc rgb "red" lt 1
set style line 2 lc rgb "blue" lt 1
set style line 3 lc rgb "purple" lt 1
set style line 4 lc rgb "orange" lt 1
set style line 5 lc rgb "cyan" lt 1
set xrange [0:780]
set yrange [0:88]
set xlabel "Time (s)"
set ylabel "Temperature (°C)"
set key bottom right
plot "data.dat" using 6:1 ls 1 notitle, "data.dat" using 6:2 ls 2 notitle, "data.dat" using 6:3 ls 3 notitle, "data.dat" using 6:4 ls 4 notitle, "data.dat" using 6:5 ls 5 notitle, \
    NaN ls 1 title "600 MHz", NaN ls 2 title "800 MHz", NaN ls 3 title "1100 MHz", NaN ls 4 title "1300 MHz", NaN ls 5 title "1500 MHz"

在此处输入图像描述

标签: gnuplot

解决方案


有不同的绘图样式,例如with pointswith lineswith linespoints许多其他样式。您还可以通过和w p缩写样式。检查。如果您不指定任何内容,则默认为. 这就是你得到的。设置线型或线型并不一定意味着您只绘制一条线。您还必须明确使用.w lw lphelp withwith pointswith lines

顺便说一句,您可以通过指定''. 并且为了可读性,您可以通过用分隔来编写多行\(注意,\必须是行中的最后一个字符,之后不允许有空格或其他字符)。

尝试以下操作:

plot "data.dat" u 6:1 w l ls 1 title "600 MHz", \
     '' u 6:2 w l ls 2 title "800 MHz", \
     '' u 6:3 w l ls 3 title "1100 MHz", \
     '' u 6:4 w l ls 4 title "1300 MHz", \
     '' u 6:5 w l ls 5 title "1500 MHz"

推荐阅读