【问题标题】:Gnuplot can't read the .dat fileGnuplot 无法读取 .dat 文件
【发布时间】:2020-04-28 22:53:26
【问题描述】:

我在记事本中创建了一个文件并将其保存为 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 文件中充满了我之前展示的数据。关于如何解决问题的任何想法?

【问题讨论】:

    标签: graph gnuplot


    【解决方案1】:

    在 gnuplot 控制台中输入pwd,它将打印当前工作目录。您的文件是否位于此目录中?如果没有给出完整路径,例如

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-04
      • 2014-10-16
      • 1970-01-01
      相关资源
      最近更新 更多