在时间序列图中指示周末并在时间序列 gnuplot 中设置 xrange
使用优秀的答案 gnuplot - Read Double Quoted datetime stamp 我已经能够绘制我的时间序列数据。
我现在尝试指示周末(或有趣的时间块)我的情节并将可见 xrange 设置为 31/1 到 28/2
今年 2 月的周末是 2/5/22 到 2/6/22 和 2/12/22 到2/13/22 等 - 我如何绘制垂直柱和阴影来指示周末或其他有趣的时间序列块?我尝试使用时间序列点(即周末1)绘制一个矩形,但我无法填充该形状。然后我尝试绘制一个矩形,但无法弄清楚如何以时间序列格式指定角点来显示它。
由于我的 x 轴是时间序列,
- 我如何在图表中指示所有周末 - 有点像日历或时间表?
- 如何将 xrange 定义为 1/31/22 到 2/28/22?
reset session
set datafile separator comma
myTimeFmt = "%m/%d/%y, %H:%M %p"
set format x "%d" time
#
# Gives error all points y value undefined!
#
# set xrange ["1/31/22, 12:01 AM":"2/28/22, 11:59 PM"] #
#
# Trying to draw a series to fill to indicate a weekend range - vertically
#
$weekend1 <<EOD
"2/5/22, 12:01 AM",0
"2/5/22, 12:01 AM",600
"2/6/22, 11:59 PM",600
"2/6/22, 11:59 PM",0
EOD
$account <<EOD
"1/31/22, 5:07 PM",1
"1/31/22, 8:01 PM",100
"2/1/22, 11:10 AM",200
"2/6/22, 12:25 PM",300
"2/9/22, 2:02 PM",400
"2/24/22, 4:22 PM",500
EOD
set object 1 rect from 1,1 to 2,2
plot $account u (timecolumn(1,myTimeFmt)):2 w lp pt 1 ps 1 lc "red" lw 1 ti "Account"
#plot $weekend1 u (timecolumn(1,myTimeFmt)):2 w lp pt 1 ps 1 lc "grey"
Using the excellent answer gnuplot - Read Double Quoted datetime stamp I have been able to plot my time series data.
I now trying to indicate weekends (or interesting timeblocks) my plot and set visible xrange to be 31/1 to 28/2
Weekends in Feb this year were 2/5/22 to 2/6/22 and 2/12/22 to 2/13/22 etc - how could I draw a vertical column and shade to indicate weekend or other interesting timeseries blocks? I looked at trying to plot a rectangle using timeseries points, ie weekend1, but I was unable to fill that shape. Then I tried to draw a rectangle, but could not work out how to specify the corners in the timeseries format to display it.
Since my x axis is a timeseries
- How could I indicate all weekends in the diagram - kind of like in a calendar or timesheet?
- How do I define the xrange to be 1/31/22 to 2/28/22?
reset session
set datafile separator comma
myTimeFmt = "%m/%d/%y, %H:%M %p"
set format x "%d" time
#
# Gives error all points y value undefined!
#
# set xrange ["1/31/22, 12:01 AM":"2/28/22, 11:59 PM"] #
#
# Trying to draw a series to fill to indicate a weekend range - vertically
#
$weekend1 <<EOD
"2/5/22, 12:01 AM",0
"2/5/22, 12:01 AM",600
"2/6/22, 11:59 PM",600
"2/6/22, 11:59 PM",0
EOD
$account <<EOD
"1/31/22, 5:07 PM",1
"1/31/22, 8:01 PM",100
"2/1/22, 11:10 AM",200
"2/6/22, 12:25 PM",300
"2/9/22, 2:02 PM",400
"2/24/22, 4:22 PM",500
EOD
set object 1 rect from 1,1 to 2,2
plot $account u (timecolumn(1,myTimeFmt)):2 w lp pt 1 ps 1 lc "red" lw 1 ti "Account"
#plot $weekend1 u (timecolumn(1,myTimeFmt)):2 w lp pt 1 ps 1 lc "grey"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我从你的问题中了解到的:绘制一些时间序列数据并通过为背景着色来突出显示周末。
实现此目的的一种可能方法是创建包含时间范围内所有日期的数据块,并绘制带有颜色的框(检查
help boxxyerror
)(检查help lc 变量
),具体取决于工作日(查看help tm_wday
)。stats
获取STATS_min
和STATS_max
(查看help stats
)。help noautoscale
)。自动缩放将仅用于数据。set yrange
和合适的框大小来设置它。我希望您可以根据您的需要调整以下示例。
脚本:
结果:
注意: 首先我以为您想绘制一个突出显示周末的日历,但是这个不是你的问题。由于我已经有了以下代码(它将绘制两个不同版本的日历),所以我仍然会发布它。也许它对您或其他人进一步的适应和优化有用。
脚本:
结果:
添加:(带有事件的日历数据文件/数据块)
脚本:
结果:
Here is what I've understood from your question: plot some time series data and highlight the weekends by coloring the background.
One possible way to get this would be to create datablock with all days within your time range and draw boxes (check
help boxxyerror
) which are colored (checkhelp lc variable
) depending of the weekday (checkhelp tm_wday
).STATS_min
andSTATS_max
fromstats
(checkhelp stats
).help noautoscale
). Autoscale will be only used for the data.set yrange
and suitable size of the boxes.I hope you can adapt the following example to your needs.
Script:
Result:
NB: first I thought you wanted to plot a calendar highlighting the weekends, but this was not your question. Since I already had the following code (which will plot a calendar in two different versions), I will post it nevertheless. Maybe it is useful to you or others for further adaptions and optimizations.
Script:
Result:
Addition: (calendar with events from a datafile/datablock)
Script:
Result: