필터 지우기
필터 지우기

add line in a datetime plot

조회 수: 3 (최근 30일)
Ancalagon8
Ancalagon8 2020년 7월 9일
댓글: madhan ravi 2020년 7월 9일
Hello I have a figure with datetime in x- axis. I want to plot a vertical line like the one you see in attached picture but through code (and not manually through insert-->line). I tried:
plot([92594 92594],get(gca,'ylim'),'linewidth',1.2,'LineStyle','--','color',[0,0.8,0])
where 92594 is the exact point but i receive an error "Values plotted against x-axis must be datetime values. To create datetime values, use the DATETIME function."
Any ideas how to do this?

답변 (1개)

Steven Lord
Steven Lord 2020년 7월 9일
First, plot some duration data.
y = (0:59);
x = duration(0, y, 1);
plot(x, y);
Now add a line at a specific value. Note that since I plotted with duration data on the X axis, when creating an xline I must create it at a duration value. If I tried something like xline(15) that wouldn't work.
xline(duration(0, 15, 0))
  댓글 수: 2
Ancalagon8
Ancalagon8 2020년 7월 9일
"Undefined function or variable 'xline'."
madhan ravi
madhan ravi 2020년 7월 9일
It was introduced in 2018b so if you’re using a prior release it won’t work.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by