我有以下数据: N的计算值
y, x
1, 8.0
10, 3.6
100, 3.36
1000, 3.212
10000, 3.152
100000, 3.14316
1000000, 3.14266
10000000, 3.1420448
100000000, 3.14190876
1000000000, 3.141573084
我正在尝试使用10^x
我使用了以下代码:
set terminal pngcairo size 1280,800 enhanced font 'Helvetica,24'
set output "fig.png"
# Title, axis label, range and ticks
set title "Simulations"
set xlabel "Number of Iterations(n)"
set ylabel "Computed values"
# Legend location and grid
set key top left
set grid
set ytics out nomirror
set xtics out nomirror
set format y "10^{%L}"
# Plot the data
plot data.dat" using 2:1 title "" with linesp lw 2 pt 7 ps 1.5
但我得到以下输出:
请帮忙
由于
答案 0 :(得分:3)
我不得不猜测你真正想要的东西,因为有些不一致。以下是我认为您想要的地方,源文件中注释的更改。
# Title, axis label, range and ticks
set title "Simulations"
set xlabel "Number of Iterations(n)"
set ylabel "Computed values"
# Legend location and grid
set datafile separator comma # gnuplot looks for spaces
# you must tell it about the comma
unset key # same as title "" as you have in your plot command
set grid
set ytics out nomirror
set xtics out nomirror
set logscale x # I guess that's what you want and how it should be
set format x "10^{%L}" # yr x axis is labeled iterations, so I guess
# that's what you want
# Plot the data
plot [][2:10] "data.dat" using 1:2 with linesp lw 2 pt 7 ps 1.5
# swapped 2:1 so that the iterations are on the x axis
# introduced a range for y so that it is better to see
# 'title ""' removed, see 'unset key'
这会给你
可能不是你想要的,但是我希望你能进入下一个层次。