我正在使用 gnuplot 5.0。每个脚本的简介如下:
set terminal epslatex 8 color standalone colortext
问题是 gnuplot 正在跳过第一行。据我所知,4.6 版本解决了类似的问题。
对这个问题有什么想法吗?
数据文件points.dat示例
4 4
4 -4
-4 4
-4 -4
第一行 (4, 4) 被跳过。因此,gnuplot 只显示三个点,而不是四个点。此命令正在使用
#!/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'
绕过该问题的技巧是复制第一行。但这不切实际。
最佳答案
使用set key autotitle columnheader
,gnuplot 使用第一行中的条目作为关键条目,即使对于您已指定notitle
的绘图。
为了演示这一点,请考虑以下脚本,使用您发布的 points.dat
中的四个数据点:
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'
即可。这会给你预期的结果。
关于gnuplot:跳过第一行数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28346228/