1

I am trying to plot two graphs using different columns from the same data file. As the range of one graph is far greater than the other, I am setting the y-axis to a logarithmic scale. As the domain of values are also very small for both graphs, I am also setting the x-axis to a logarithmic scale.

I have no problem plotting the graphs except that gnuplot does not plot the first points in the data file (where x = 0).

The code that I am using to plot the graphs is thus:

set xrange [1:2500]
set yrange [1:2000]
set log x
set log y
plot "datafile.txt" using 1:2 with lines, "datafile.txt" using 1:3 with lines

Note that, because I am using a logarithmic scale for both axes, I cannot include the value of zero in either range.

An excerpt of the data file that I am using is thus:

Table of Results: Range: {-50...50}
Dim #AvgP   #AvgNP
0   0   1743
1   0   564
2   0   914
3   0   1040
4   0   1072
5   0   1005
6   0   815
7   1   689
8   3   525
9   4   433
10  3   350
11  0   255
12  1   216
13  2   140
14  2   84
15  1   57
16  0   38
17  0   16
18  0   15
19  1   7
20  0   2
21  0   1
22  0   1
23  0   0
24  0   0
25  0   0
.   .   .
.   .   .
.   .   .

The file that is plotted is thus:

enter image description here

Notice how the first value of the second graph is not plotted.

4

1 回答 1

0

正如您所注意到的,x=0点未在对数轴上定义,因此您应该期望它被省略。如果您想强制包含该点,请通过将每个值加 1 来移动x值,并提供适当的轴标签以明确绘制的内容。

plot "datafile.txt" using ($1+1):2 with lines, "datafile.txt" using ($1+1):3 with lines

有了这个,你应该看到绿线上的缺失点。红线将保持不变,因为值y=0也无法绘制。如果需要,您也可以移动y值。

这是它的外观: 曲线移动以显示第一个点。

于 2011-11-02T09:00:09.837 回答