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

Nil*_*ils 8 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" wit
Run Code Online (Sandbox Code Playgroud)

得到的图可以在这里找到:1

我尝试使用xtics但它没有将x轴移动到1开始但只是在1处开始刻度.如何移动x轴使其从1开始到50结束?

更新

下面是Datafile 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
Run Code Online (Sandbox Code Playgroud)

Wol*_*tan 10

xtics只是为了"标记"x轴.您正在寻找的是某种"数据操纵".我建议using像这样使用:

plot "cpuTimes.txt" u ($0+1):1 t "CPU" w lp, \
     "gpuTimes.txt" u ($0+1):1 t "GPU" w lp
Run Code Online (Sandbox Code Playgroud)

为了使绘图结束为50,有两种方法:

  1. 您可以使用set xrange [1:50]或指定x范围

    plot [1:50] "cpuTimes.txt" u ($0+1):1 t "CPU" w lp, \
                "gpuTimes.txt" u ($0+1):1 t "GPU" w lp
    
    Run Code Online (Sandbox Code Playgroud)
  2. 你需要every像这样包括:

    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
    
    Run Code Online (Sandbox Code Playgroud)

    请参阅每个文档以供进一步参考.