Gnuplot 如何将x轴的起点指定为1而不是0

Gnuplot 如何将x轴的起点指定为1而不是0,gnuplot,Gnuplot,我使用gnuplot根据数据大小绘制在CPU和GPU上测量的执行时间。我有两个文件,里面有执行时间。策划它们是直截了当的 set title "CPU vs GPU" set xlabel "Number of Particles (* 10'000)" set ylabel "Time in Microseconds" plot "cpuTimes.txt" title "CPU" with linespoints, \ "gpuTimes.txt" title "GPU" wi

我使用gnuplot根据数据大小绘制在CPU和GPU上测量的执行时间。我有两个文件,里面有执行时间。策划它们是直截了当的

set title "CPU vs GPU"

set xlabel "Number of Particles (* 10'000)"
set ylabel "Time in Microseconds"

plot "cpuTimes.txt" title "CPU" with linespoints, \
     "gpuTimes.txt" title "GPU" wit
结果图可在此处找到:

我尝试使用
xtics
,但是它不会将x轴从1开始移动,而是从1开始。如何移动x轴,使其从1开始到50结束

更新

下面的数据文件cpuTimes.txt

64780
129664
195490
266697
327871
391777
459150
517999
582959
647984
717377
790415
830869
900475
959599
1026041
1092899
1156022
1297471
1286325
1349227
1415936
1482857
1539580
1607389
1673436
1737098
1801568
1874431
1935975
2006892
2053077
2129867
2195117
2254467
2314478
2373546
2435416
2506850
2587302
2625556
2674799
2758387
2820720
2896794
2953550
3053817
3089501
3170513
3271537

在plot命令中指定轴范围:

plot [1:50] "cpuTimes.txt"

我已经有一段时间没有使用gnuplot了,但是我相信您可以使用
setxrange
来调整绘制的内容

在您的情况下,命令是:

set xrange [ 1 : 50 ]

XTIC
仅用于“标记”x轴。你要找的是某种“数据操纵”。我建议使用
这样使用

plot "cpuTimes.txt" u ($0+1):1 t "CPU" w lp, \
     "gpuTimes.txt" u ($0+1):1 t "GPU" w lp
plot "cpuTimes.txt" u ($0+1):1 every 1::::50 t "CPU" w lp, \
     "gpuTimes.txt" u ($0+1):1 every 1::::50 t "GPU" w lp
要使绘图结束于50,有两种方法:

  • 您可以使用
    设置xrange[1:50]

    plot [1:50] "cpuTimes.txt" u ($0+1):1 t "CPU" w lp, \
                "gpuTimes.txt" u ($0+1):1 t "GPU" w lp
    
  • 您需要包括
    每个
    ,如下所示:

    plot "cpuTimes.txt" u ($0+1):1 t "CPU" w lp, \
         "gpuTimes.txt" u ($0+1):1 t "GPU" w lp
    
    plot "cpuTimes.txt" u ($0+1):1 every 1::::50 t "CPU" w lp, \
         "gpuTimes.txt" u ($0+1):1 every 1::::50 t "GPU" w lp
    
    有关更多参考,请参阅文档


  • 试过绘图[1:50]“cpuTimes.txt”标题“CPU”与线条点不起作用。啊,它似乎影响y轴,但不影响x轴,它应该会影响x-axis@Nils如果您提供了数据文件的一个片段,则更容易看到发生了什么。有些人会说,选择轴来隐藏数据是误导性的…@Tom我认为Nils只有一列数据。然后默认情况下,gnuplot星标绘为0。然而,这是武断的。另一方面,我可能只是没有正确理解这个问题。