gnuplot画散点图
直接弹出结果图,不生成eps或者其他格式的图片
如果只是想要简单看一下实验结果,可以使用这种方法,语句比较简便:
先贴代码:
set xlabel “distance”
set ylabel “Query time(ms)”
file = “example.dat”
plot file using 3:4 title “A1”
首先是设置xy轴的名称。file是说明调用的是文件“distanceg.dat”中的数据。plot是说明使用文件中的第3列数据作为x轴的数据,第4列作为图中y轴的数据,进行绘图。title是图里的名称。最后运行输出会弹出一个弹框,显示实验结果图。
生成eps格式图片
一般在写论文的时候,需要用到eps格式的图片,这里有些地方设置会有些不同:
代码:
set terminal postscript eps enhanced #生成的图片格式设置为eps
set output “example.eps” #输出的图片名称为“example.eps”
set xlabel “distance” font ‘times.ttf,40’ offset 0,-2,0 #设置x轴的名称,字体,字号以及距离轴线的距离
set ylabel “Query time(ms)” font ‘times.ttf,40’ offset -3,0,0 #同x轴
set xtics font 'times.ttf,30’offset 0,-1,0 #设置x轴刻度的字体大小,字号以及距离轴线的距离
set ytics font ‘times.ttf,30’ #同x轴
file = “example.dat” #调用的文件名称
plot file using 3:4 title “A1” #利用文件中的第3,4列进行绘图,第三列数据作为x轴,第四列数据作为y轴。
最后运行输出的图片即为eps格式。另外,如果想要的是PNG格式的图片,应该只需要改变上面代码的前两行,改为:
set terminal png
set output “example.png”