在Gnuplot中使用不同的点样式绘制曲线

4
我正在使用Gnuplot绘制图形。在图形中,我绘制了三条属于三个数据集的平滑曲线。
目前,我正在使用以下Gnuplot脚本。
reset
set terminal png
set xlabel "Square matrix size"

set ylabel "Time (in milliseconds)"
set yrange [0:750]

set title "Lower Triangular Matrix"
set key reverse Left outside
set grid
set output 'matrixlt.png'
set style data linespoints
plot "matrixlowertriangle.dat" using 1:2 lt 1 lw 2 smooth bezier title 'MatPro', \
     "matrixlowertriangle.dat" using 1:3 lt 2 lw 2 smooth bezier title 'C#' , \
     "matrixlowertriangle.dat" using 1:4 lt 3 lw 2 smooth bezier title 'C++'

使用上述脚本我得到了以下图表。 enter image description here 现在我想使用唯一的点样式绘制属于同一曲线的每个点。(例如,属于C#的每个点使用一个点类型,而C++数据点则使用不同的样式。)
我尝试过一些教程,但仍然没有成功。有人能帮我完成这个任务吗?
3个回答

7

我没有你的数据,所以我编了一些(如果提供了一些有用的模拟数据,总是有帮助的...):

0   0   0   0
200 1000    1200    1500
400 4000    7000    9000
600 7000    15000   18000
800 12000   23000   25000
1000    18000   33000   40000

根据你的代码,我尝试了
reset
set terminal png
set xlabel "Square matrix size"

set ylabel "Time (in milliseconds)"
set xrange [0:1200]
set yrange [0:50000]


set title "Lower Triangular Matrix"
set key reverse Left outside
set grid
set output 'matrixlt.png'
set style data linespoints
plot "matrixlowertriangle.dat" using 1:2 lt 1 lw 2 smooth bezier title 'MatPro', \
     "matrixlowertriangle.dat" using 1:3 lt 2 lw 2 smooth bezier title 'C#' , \
     "matrixlowertriangle.dat" using 1:4 lt 3 lw 2 smooth bezier title 'C++' , \
     "matrixlowertriangle.dat" using 1:2 with points title "", \
     "matrixlowertriangle.dat" using 1:3 with points title "", \
     "matrixlowertriangle.dat" using 1:4 with points title ""

并且得到了:

这里的图表

这是否更接近你想要的内容?


2

你是否尝试过在绘图参数中提供pointtype X (其中X是一个数字)?


我认为最好您编辑一下您的问题,并添加有关您的gnuplot构建的一些信息。 - ziu

0

我认为你的问题与使用PNG终端有关。你必须使用PNG格式吗?如果你尝试使用set terminal postscript enhanced eps color,脚本将生成具有清晰可辨的线条类型的图形。

例如,运行以下简单脚本:

set terminal postscript enhanced eps color
set yrange [0:10]
set grid
set output 'test.eps'
set title 'EPS demonstration'
set style data linespoints

plot x*2 lt 1 lw 2 title 'A', \
     x**2 lt 2 lw 2 title 'B'

显示两条不同类型的线。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接