Gnuplot:以10^x的形式格式化yaxis
我有以下数据: Nπ的计算值Gnuplot:以10^x的形式格式化yaxis,gnuplot,Gnuplot,我有以下数据: 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
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来格式化y轴
我使用了以下代码:
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
但我得到了以下输出:
请帮忙
谢谢我不得不猜测你真正想要什么,因为有些不一致。下面是我相信能带给你想要的东西,在源文件中注释的更改
# 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'
这给你
可能不完全是你想要的,但我希望这会让你进入下一个层次。我不得不猜测你真正想要的是什么,因为有一些不一致之处。下面是我相信能带给你想要的东西,在源文件中注释的更改
# 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'
这给你
也许不完全是你想要的,但我希望这会让你更上一层楼