Using copyobj to copy lines plotted with datetime xdata

조회 수: 1 (최근 30일)
Kevin J. Delaney
Kevin J. Delaney 2017년 8월 25일
댓글: Xiaoyi Zhao 2020년 11월 20일
Matlab returns a warning "Error updating Line. Value must be a vector of numeric type" when I use copyobj to copy a line object in which the XData are datetimes, not numeric. Is there a way to prepare the new axes to receive lines plotted with datetime? Is there a datetime-tolerant version of copyobj?
  댓글 수: 1
Xiaoyi Zhao
Xiaoyi Zhao 2020년 11월 20일
I had similar issue for a longtime, and I was "solving" them by simply plot timeserise with "datenum" (i.e., the MATLAB serieal time) not "datetime". But, the simple/real solution should be this:
For the traget figure
set(gca, 'XAxis', matlab.graphics.axis.decorator.DatetimeRuler);
Then, you could do the copyobj which the XData are datetime.

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

채택된 답변

Walter Roberson
Walter Roberson 2017년 8월 25일
First you have to set the XRuler property of the second axes to be a DateTime ruler, such as
L = ... the line object
ax = ancestor(L, 'axes');
nax = axes();
nax.XRuler = ax.XRuler;
copyobj(L, nax)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by