【问题标题】:Problem with gnuplot - timestamp data mapping to xrangegnuplot 的问题 - 时间戳数据映射到 xrange
【发布时间】:2018-12-21 11:52:29
【问题描述】:

我有什么:

第一列中带有时间戳的 csv 数据,之后我想有选择地绘制列。 每个数据点大约相隔十分钟。数据为 24 小时。其他一切都设置得很好,下面的例子

我想要什么:

能够在 x 轴 (xrange?) 上绘制格式化的时间数据。就像xticsn 小时,以给定的格式(如"%T, %A")。我想绘制的每列的最佳配置(考虑多图)。

数据:

1545389400,39,0,0,1,664,2493,31.7
1545390000,37,0,0,1,736,3093,32.5
1545391200,33,0,0,1,664,4293,32.6
1545392400,28,0,0,1,704,5493,31.3
1545393000,26,0,0,0,649,6093,30.8
1545393600,24,0,0,0,632,6693,30.5

代码:

set title "Battery Log"
set datafile separator ','
set key center bottom outside
set border lw 0.5 lc '#959595'
set terminal svg dynamic rounded mouse lw 1 background '#272822'
set grid ytics
set ytics nomirror in
set yrange [0:100]
set xtics nomirror
set xtics rotate
set xdata time
set timefmt "%s"
set format x "%T, %A"
plot 'stats.csv' \
    u 0:2 w l lc '#f92783' t columnheader, '' \
    u 0:8 w l lc '#a6e22a' t columnheader

【问题讨论】:

  • 你能澄清一下“我想要什么”部分吗?
  • 当然,问题更新了!

标签: gnuplot scale unix-timestamp xrange


【解决方案1】:

这个怎么样?

### set time xtics

N = 3  # every n-th hour

set samples 100
set xdata time 
set format x "%a, %H:%M"
set xtics rotate
set xtics N*3600

plot '+' u ($0*1200):(3*sin(x)+rand(0)) w lp pt 7 not
### end of code

应该给出这样的结果,每 3 小时打勾。 根据您要绘制的列设置您的N

【讨论】:

  • 感谢您的回答。那么这对我的代码有什么帮助呢?你能解释一下如何使这个解决方案适应我的问题吗?
  • 您希望每 N 小时抽动一次。所以,只需使用set xtics N*3600。我不知道你的 gnuplot 水平,而且我没有足够的数据来说明每 3 小时一次,所以我不得不生成自己的虚拟数据。顺便说一句,您正在绘制与伪列 0 的图。如果第 1 列包含您的时间数据,您应该plot 'stats.csv' u 1:2,另请参阅help set xdata time。 “每列可配置”是什么意思?不同情节的不同时间表示或抽动距离?只需为每个绘图设置不同的时间格式或 xtic。
猜你喜欢
  • 1970-01-01
  • 2012-01-21
  • 1970-01-01
  • 2020-05-15
  • 2011-10-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-15
  • 2022-10-05
相关资源
最近更新 更多