Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gnuplot:使用xtic时如何指定标签格式_Gnuplot - Fatal编程技术网

Gnuplot:使用xtic时如何指定标签格式

Gnuplot:使用xtic时如何指定标签格式,gnuplot,Gnuplot,在my file.dat中,值采用如下科学格式: 0.00000000E+00 0.00000000E+00 0.70000000E+01 -0.27957985E+01 0.26000000E+02 -0.85755510E+01 ... 我想在绘图中直接使用这些值作为x和y标签,但采用十进制格式。我在我的情节脚本中有这样的内容: set format x '%.1f' set xtics format "%.1f" rotate by +40 right plot

在my file.dat中,值采用如下科学格式:

0.00000000E+00    0.00000000E+00  
0.70000000E+01  -0.27957985E+01  
0.26000000E+02  -0.85755510E+01  
...  
我想在绘图中直接使用这些值作为x和y标签,但采用十进制格式。我在我的情节脚本中有这样的内容:

set format x '%.1f'
set xtics format "%.1f" rotate by +40 right
plot"file.dat" u 1:2:xtic(1):ytic(2) t 'xxx' w l ls 1 lc rgb "blue" lw 2

但是标签以科学格式显示(如“file.dat”中),而不是十进制格式。为什么?

之所以会发生这种情况,是因为使用
设置格式x
可以更改标准用法中x标签的格式。当您传递
xtic()
时,您告诉gnuplot重写标准值并使用提供的值作为标签。要在这种情况下更改格式,需要将格式说明符传递到
xtic()
。这应该适合您:

plot "file.dat" u 1:2:xtic(sprintf("%.1f", $1)):ytic(sprintf("%.1f", $2))