gpt4 book ai didi

time - x 轴上的 Gnuplot 日期和时间

转载 作者:行者123 更新时间:2023-12-04 20:06:29 24 4
gpt4 key购买 nike

我想要做的是绘制一个图表,其中我的 x 轴从第一列数据中获取日期,然后从第二列中获取时间,并使用两者来创建 x 轴,
我有一组来自日期记录器的数据,我想在 gnuplot 上绘制它们,因为我每天都在获取新数据,并且在获取它们时添加每个 txt 文件会非常容易
文本文件如下所示(每个跨度为 24 小时)

Date Time Value

30/07/2014 00:59:38 0.075
30/07/2014 00:58:34 0.102
30/07/2014 00:57:31 0.058
30/07/2014 00:56:31 0.089
30/07/2014 00:55:28 0.119
30/07/2014 00:54:26 0.151
30/07/2014 00:53:22 0.17
30/07/2014 00:52:19 0.171
30/07/2014 00:51:17 0.221
30/07/2014 00:50:17 0
30/07/2014 00:49:13 0
30/07/2014 00:48:11 0
30/07/2014 00:47:09 0


此解决方案 mixing date and time on gnuplot xaxis非常适合我,但它非常复杂,我不知道发生了什么,更不用说将它应用于多个文件
这是我试过的代码,但我收到了非法日期错误?
#!/gnuplot
set timefmt '%d/%m/%Y %H:%M:%S'
set xdata time
set format x '%d/%m/%Y %H:%M:%S'



#DATA FILES
plot '30.07.2014 Soli.txt' using 1:3 title '30/07/2014' with points pt 5 lc rgb 'red',\
'31.07.2014 Soli.txt' using 1:3 title '31/07/2014' with points pt 5 lc rgb 'blue'
所有帮助表示赞赏!谢谢

最佳答案

如果数据文件中出现一些意外数据,例如在您的案例中取消注释和未使用的标题行,则会触发此类错误。

以下file.dat

Date Time Value
30/07/2014 00:59:38 0.075
30/07/2014 00:58:34 0.102

用最小的脚本给出这样的错误
set xdata time
set timefmt '%d/%m/%Y %H:%M:%S'
plot 'file.dat' using 1:3

要解决错误,请删除第一行(或中间的类似行)。

从 4.6.6 版开始,您还可以使用 skip跳过数据文件开头的某些行的选项,例如:
set xdata time
set timefmt '%d/%m/%Y %H:%M:%S'
plot 'file.dat' using 1:3 skip 1

关于time - x 轴上的 Gnuplot 日期和时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25076264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com