gnuplot - 读取双引号日期时间戳
我正在尝试学习 gnuplot,我想绘制一些逗号分隔的数据。
- x 轴日期时间戳 - 用双引号括起来 - 包含逗号分隔符,
- y 轴整数值数据。
"1/31/22, 4:36",0
"1/31/22, 16:30",1
"1/31/22, 16:39",2
"2/1/22, 16:44",3
"2/1/22, 9:25",4
"2/7/22, 13:59",5
"2/7/22, 8:57",6
"2/8/22, 11:03",7
"2/18/22, 15:50",8
"2/21/22, 11:11",9
"2/24/22, 9:11",10
如何读取这些数据并在 gnuplot 中绘图?
我尝试了以下操作,但收到有关“警告:跳过没有有效点的数据文件”的错误,
set xdata time
set timefmt "\"%m/%d/%Y, %H:%M\""
set format x “%d/%m/%Y”
set datafile separator ","
plot "file.txt" using 1:2 with linespoints
我认为我的 timefmt 不正确。正确的语法是什么?
gnuplot 还可以使用 AM/PM 处理以下格式的日期时间戳吗?
"1/31/22, 4:36 AM",0
"1/31/22, 4:30 PM",1
I am trying learn gnuplot and I want to to plot some comma separated data.
- x axis datetime stamp - enclosed in double quotes - containing a comma separator,
- y axis integer value data.
"1/31/22, 4:36",0
"1/31/22, 16:30",1
"1/31/22, 16:39",2
"2/1/22, 16:44",3
"2/1/22, 9:25",4
"2/7/22, 13:59",5
"2/7/22, 8:57",6
"2/8/22, 11:03",7
"2/18/22, 15:50",8
"2/21/22, 11:11",9
"2/24/22, 9:11",10
How do I read this data and plot in gnuplot?
I tried the following but get error about "warning: Skipping data file with no valid points"
set xdata time
set timefmt "\"%m/%d/%Y, %H:%M\""
set format x “%d/%m/%Y”
set datafile separator ","
plot "file.txt" using 1:2 with linespoints
I assume my timefmt is incorrect. What is the correct syntax?
Also can gnuplot process datetime stamps in the following format with AM/PM?
"1/31/22, 4:36 AM",0
"1/31/22, 4:30 PM",1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查
帮助时间说明符
。您的年份是 2 位数字%y
,而不是 4 位数字%Y
。双引号将使您的日期/时间成为第一列。格式中不需要额外的双引号。
使用语法
set xdata time
和set timefmt "..."
在绘图命令中只有一种格式。如果您使用语法
timecolumn()
(请查看help timecolumn
),您可以在绘图命令中使用不同的输入时间格式。注意:格式
%p
作为输入格式已在 gnuplot 5.4.0 中引入对于旧版本,您必须使用解决方法,请参阅 gnuplot:如何将 12 小时时间格式转换为 24 小时时间格式?
<强>代码:
结果:
Check
help time_specifiers
. Your year it 2 digits%y
not 4 digits%Y
.The double quotes will make your date/time the first column. No need for extra double quotes in the format.
With the syntax
set xdata time
andset timefmt "..."
you have only one format in the plot command.If you are using the syntax
timecolumn()
(checkhelp timecolumn
) you can use different input time formats in your plot command.Note: the format
%p
as input format has been introduced in gnuplot 5.4.0For older versions you have to use a workaround, see e.g. gnuplot: how to convert 12h time format into 24h time format?
Code:
Result: