add vertical lines using xline
10 次查看(过去 30 天)
显示 更早的评论
Hi,
I have the following graphs. There are 2 graphs in 1 figure and in x axis are date and times.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/906760/image.png)
I would like to add vertical lines using the command xline but i cannot find how to use it in date and times.
E.g. I want to add a vertical line at 20/01 7.00am
Thank you
0 个评论
采纳的回答
Star Strider
2022-2-25
It would helpo to understand what the dates are in the posted code.
figure
xline(datetime('20/01 7:00am', 'InputFormat','dd/MM hh:mma'))
The 'InputFormat' string may need to be changed to ocnform with the units on the x-axis.
.
1 个评论
Walter Roberson
2022-2-25
Note: if you are still using serial date numbers together with datetick() then the approach shown here will not work: you would need to pass a serial data number to xline() for that case.
Likewise if you are passing in year + fraction of a year to plot() then the approach shown here will not work: you will need to pass the appropriate year + fraction of a year to xline() in that case.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!