【发布时间】:2015-12-16 16:55:06
【问题描述】:
我正在尝试使用 gnuplot 绘制图表。我想把一天中的时间放在 x 轴上。我设法使用以下代码做到了这一点:
set term postscript eps enhanced color "Times" 24
set output "DailyAvailability.eps"
set xtics rotate by -45 font ",18"
set xdata time
set timefmt '%Y-%m-%d %H'
set format x '%H:%M'
set ylabel "Number of peers"
set xlabel "Time of the day [in hours]"
set yrange [0:30]
set xrange ['2015-12-30 15:50':'2015-12-30 16:00']
set key right top #FFA500"
plot "intervals.dat" using 1:2 lc rgb "#000077" t "availability" w lines
这是我的输入数据
"2015-12-30 15:59" 6
"2015-12-30 15:58" 10
"2015-12-30 15:57" 17
"2015-12-30 15:56" 18
"2015-12-30 15:55" 19
"2015-12-30 15:54" 20
"2015-12-30 15:53" 18
"2015-12-30 15:52" 28
"2015-12-30 15:51" 23
执行代码后,我得到了图表,但其中没有画线。我尝试阅读其他问题,但我看不出他们的代码与我的 Gnuplot date/time in x axis 之间有任何重大差异。我还检查了输入文件中的空格,但由于没有错误或警告消息,我无法弄清楚发生了什么。任何人都可以看到我在这里缺少什么吗?感谢您的宝贵时间!
【问题讨论】:
-
@F.Knorr 为您提供真正的答案,解决方法是
plot "intervals.dat" using 0:2:xtic( substr( stringcolumn( 1 ), 12, 16 ) ) lc rgb "#000077" t "availability" w lines