【问题标题】:Gnuplot error in ploting histogram with xdate使用 xdate 绘制直方图时出现 Gnuplot 错误
【发布时间】:2014-01-02 10:13:18
【问题描述】:

我正在尝试使用 xtics 作为时间信息绘制直方图。我正在使用的 gp 脚本是这个:

set style data histogram
set style histogram cluster gap 1
set boxwidth 1

set datafile separator "\t"
set yrange[0:3000]
set xlabel "xaxis"
set ylabel "yaxis"
set xdata time
set timefmt "%Y-%m-%d %H"


set terminal png size 1200,800
set output outputfile
plot inputfile u 2:1 title "Count"

我的输入文件(我通过参数传递)的一个例子是这个:

2012-07-22 00:00:00    159.361111111
2012-07-22 01:00:00    207.019166667
2012-07-22 02:00:00    191.749722222
2012-07-22 03:00:00    147.647777778
2012-07-22 04:00:00    107.751388889
2012-07-22 05:00:00    95.9566666667
2012-07-22 06:00:00    110.405277778
2012-07-22 07:00:00    151.689166667
2012-07-22 08:00:00    244.787777778
2012-07-22 09:00:00    481.601388889

但是我收到错误“plot_timeflow.gp”,第 16 行:使用规范时的列太多,当我尝试将 plot 命令设置为绘制 inputfile u 2:xticlabels(1) 标题“Count”时以下错误:“plot_timeflow.gp”,第 16 行:需要完整使用 x 时间数据的规范。

有人有什么想法,有什么问题吗??

提前致谢。

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    确实很奇怪。但无论如何,对于您的数据,boxes 绘图风格更好,因为使用histograms,每个框都有自己的 xtic。使用boxes,x 轴被视为正常时间轴:

    set boxwidth 0.8 relative
    set datafile separator "\t"
    set yrange[0:3000]
    set xlabel "xaxis"
    set ylabel "yaxis"
    set xdata time
    set timefmt "%Y-%m-%d %H"
    
    set style fill solid
    
    plot 'data.txt' using 1:2 with boxes title "Count"
    

    这给了:

    【讨论】:

    • 非常感谢。这正是我需要的。我以为每次要制作直方图时都应该使用“设置样式数据直方图”。对我来说,用方框绘图似乎要简单得多,结果相同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-22
    • 2013-12-22
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    • 1970-01-01
    相关资源
    最近更新 更多