【问题标题】:Problem with gnuplot in the construction of the histogramgnuplot 在直方图构建中的问题
【发布时间】:2019-01-18 10:33:28
【问题描述】:

大家:

在以直方图的形式表示数据时,我遇到了问题。 我不太清楚如何清楚地表达我的意图,但我的想法是:

  • 3 组列(碳化物、硼化物和氮化物)
  • 在每组色谱柱中,4 根色谱柱(铪、锆、钛和 钽)每个都有一个网格类型。

到目前为止,我已经完成了下面显示的操作,但它不允许我继续

我当前的代码是:

reset
fontSpec(s) = sprintf("Times-Roman, %d", s)
set term post eps enhanced fontSpec(16)
set output 'TVsG.eps'

set grid
set auto y
set auto x

ticsFont=fontSpec(16)
set xtics font ticsFont
set ytics font ticsFont

set ylabel "Temperature" font fontSpec(25) offset char -1,0
set xlabel "Group" font fontSpec(25) offset 0,char -1

set style fill pattern border -1
set style data histograms
set boxwidth 1.0
set style histogram clustered gap 1

keyFont=fontSpec(18)
set key spacing 2 font keyFont
set key at graph 0.25, 0.9

fn(v) = sprintf("%.1f", v)

plot \
    for [COL=2:4] 'data.txt' using COL:xticlabels(1) title columnheader fs 
pattern 2, \
    'data.txt' u ($0-1-1./6):2:(fn($2)) w labels font fontSpec(14) offset 
 char 0,0.5 t '' , \
     'data.txt' u ($0-1-1./6):2:(fn($3)) w labels font fontSpec(14) offset 
 char 0,0.5 t '' , \
    'data.txt' u ($0-1+1./6):3:(fn($4)) w labels font fontSpec(14) offset 
char 0,0.5 t ''

还有我的数据文件

Material    Hafnium Zirconium   Titanium    Tantalum
Carbide 3958    3400    3100    3768  
Boride  3380    3245    3225    3040        
Nitride 3385    2950    2950    2700      

我现在遇到的主要问题是以下错误:

gnuplot> load 'gnuplot2.txt'
         "gnuplot2.txt" line 34: warning: Cannot find or open file "data"
         "gnuplot2.txt" line 34: warning: Cannot find or open file "data"
         "gnuplot2.txt" line 34: warning: Cannot find or open file "data"
         "gnuplot2.txt" line 34: warning: Cannot find or open file "data"
         "gnuplot2.txt" line 34: warning: Cannot find or open file "data"
         "gnuplot2.txt" line 34: warning: Cannot find or open file "data"
         "gnuplot2.txt" line 34: No data in plot

现在我到了一个点,我不知道如何继续

【问题讨论】:

    标签: label gnuplot histogram


    【解决方案1】:

    Gnuplot 没有找到数据文件。我看到两个可能的原因:

    1. 数据文件名错误

    该脚本有类似plot "data.txt" 的内容,错误消息提到了一个文件"data",请注意缺少的.txt。 => 检查您的脚本和实际文件名,这可能是一个简单的拼写错误或缺少文件扩展名。

    1. 数据文件不在预期的目录中。

    添加命令pwd(打印工作目录)作为脚本中的第一个命令。它将打印需要数据文件的目录。如果不是正确的目录,可以:

    • 将您的数据文件移动或复制到此目录
    • 使用cd 命令切换到正确的目录
    • 从正确的目录启动 gnuplot
    • plot命令与包含路径信息的文件名一起使用

    您使用load 命令,gnuplot 似乎找到了脚本。所以我认为数据文件很可能应该与脚本gnuplot2.txt在同一目录中。

    【讨论】:

      【解决方案2】:

      So far, this is the image that I have

      确实,问题出在选择数据所在的目录时。

      现在的问题是我不知道如何更改格式以赋予它不同的颜色。此外,我想在每列的顶部添加复合标签。

      有什么建议吗?

      【讨论】:

      • 如果答案确实有帮助,请考虑接受它。如果还有其他问题,请再问一个问题。请不要在答案中隐藏您的问题。
      猜你喜欢
      • 1970-01-01
      • 2012-11-05
      • 1970-01-01
      • 2013-07-28
      • 2017-08-25
      • 2016-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多