Gnuplot 无法读取 .dat 文件

Gnuplot can't read the .dat file

我在记事本中创建了一个文件并将其另存为 ANSI 和 .dat 文件。文件结构如下:

2019 371320
2018 352137
2017 323201
2016 302271
2015 291377
2014 282730
2013 273467
2012 257093
2011 244541
2010 223488
2009 216949
2008 197778
(...)

然后 gnuplot 终端被打开,我设置了我想要的设置,在 plot "dates1.dat" using 2:xticlabels(1) with boxes lt rgb "#406090" 之后弹出一个错误:

Warning! Cannot find or open file "dates1.dat"
         No data in plot

整个设置:

# Output to PNG, with Verdana 8pt font
set terminal pngcairo nocrop enhanced font "verdana,8" size 640,300

# Don't show the legend in the chart
set nokey 

# Thinner, filled bars
set boxwidth 0.4
set style fill solid 1.00 

# Set a title and Y label. The X label is obviously months, so we don't set it.
set title "Number of registrations per month" font ",14" tc rgb "#606060"
set ylabel "Registrations (thousands)"

# Rotate X labels and get rid of the small stripes at the top (nomirror)
set xtics nomirror rotate by -45

# Show human-readable Y-axis. E.g. "100 k" instead of 100000.
set format y '%.0s %c'

# Replace small stripes on the Y-axis with a horizontal gridlines
set tic scale 0
set grid ytics lc rgb "#505050"

# Remove border around chart
unset border

# Manual set the Y-axis range
set yrange [100000 to 300000]

set output "6.png"
plot "dates1.dat" using 2:xticlabels(1) with boxes lt rgb "#406090"

dates1.dat 文件充满了我之前显示的数据。关于如何解决这个问题有什么想法吗?

在 gnuplot 控制台中键入 pwd,这将打印当前工作目录。您的文件位于此目录中吗?如果不是,请给出完整路径,例如

plot 'C:/myDir/subDir/dates1.dat' ... 

或使用 cd 更改工作目录。检查 help pwdhelp cd.