gnuplot:跳过第一行数据 [英] gnuplot: first row of data skipped
问题描述
我使用gnuplot 5.0.每个脚本的序言如下:
Am using gnuplot 5.0. with the following as pereamble to each script:
set terminal epslatex 8 color standalone colortext
问题在于gnuplot跳过了第一行.据我所知,4.6版本解决了类似的问题.
The issue is that gnuplot is skipping the first row. To my knowledge 4.6 version addressed a similar issue.
数据文件points.dat的示例
Example of data file points.dat
4 4
4 -4
-4 4
-4 -4
第一行(4,4)被跳过.因此,gnuplot仅显示三个点,而不是四个点.此处命令正在使用
The first line (4, 4) is skipped. So instead of four points, only three are displayed by gnuplot. Herewith the command am using
#!/bin/bash
set terminal epslatex 8 color standalone colortext
set output outputFileName
set size .55,.55
set pointsize 3.0
##############
# Line styles
##############
set linestyle 1 lt 5 lw 1 #
set linestyle 2 lt 2 lw 1.5
set linestyle 3 lt 6 lw 1 #
set linestyle 4 lt 3 lw 1
set linestyle 5 lt 2 lw 2 #
set linestyle 6 lt 1 lw 2
##################
# Titles
##################
set title 'Image'
set xlabel '$x$' offset 0,0.5
set ylabel '$y$' offset 2,0
set macros
filename_init = sprintf("%s/image_init.dat",dataFileDirectory)
set key autotitle columnhead
set key horiz
set multiplot
plot
filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta" notitle 'initial'
绕过该问题的技巧是复制第一行. Bu这是不切实际的.
On trick to bypass the issue is to duplicate the first row. Bu this is not practical.
推荐答案
对于set key autotitle columnheader
,gnuplot会将第一行中的条目用作键条目,即使对于图而言,您已经指定了notitle
.
With set key autotitle columnheader
gnuplot uses the entries in the first row as key entries, even though for the plot you have specified notitle
.
为证明这一点,请考虑以下脚本,并使用您发布的points.dat
中的四个数据点:
To demonstrate this, consider the following script, using the four data points in points.dat
, which you posted:
set terminal pngcairo
set output 'foobar.png'
set offsets 1,1,1,1
set key autotitle columnhead
filename_init = 'points.dat'
set multiplot layout 1,2
plot filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta"
set key noautotitle
plot filename_init u 1:2 with points lt 0 pt 1 lw 5 lc rgb "magenta" title 'initial'
unset multiplot
结果是
因此,只需从脚本中删除行set key autotitle columnhead
,然后使用plot ... title 'initial'
.这样可以给您预期的结果.
So, just remove the line set key autotitle columnhead
from your script, and use plot ... title 'initial'
. That gives you the expected result.
这篇关于gnuplot:跳过第一行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!