Hist3 axis scale (time)

조회 수: 5 (최근 30일)
Richard Youden
Richard Youden 2018년 7월 10일
댓글: dpb 2018년 7월 11일
I have a data logger collecting data at 1Hz. Therefore in a histogram each count in a column is equivalent to 1 second. With the data am able to generate a 3D histogram using the hist3 function and everything looks good.
What I'd like to do is change the z-axis from a cumulative count to a time value in the hh:mm:ss format.
Attached is what the axis currently looks like:
I tried this:
datetick('z','hh:mm:ss');
But no joy.
Any suggestions? Thanks.
  댓글 수: 1
dpb
dpb 2018년 7월 10일
For datenum which datetick works with, time is in fractions of days; not at all same scale as histogram counts.
I can find no way with builtin hist3 or bar3 to force acceptance of a duration variable for an axis...
Only thing I can think of would be to scale the counts from the zlim and ztick arrays to the desired duration values and then write tick labels manually.
I've gotta'nother commitment at moment; I'll try to see if can get back and make that work later on this evening if you can't find a way or somebody else doesn't find a better hack before...

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

답변 (1개)

dpb
dpb 2018년 7월 11일
편집: dpb 2018년 7월 11일
hAx=gca; % handle to current axes
du=seconds(interp1(zlim,zlim,hAx.ZTick)); % make duration array match ticks scaled to axis limits
du.Format='hh:mm:ss'; % set format
hAx.ZTickLabel=cellstr(du); % write tick labels to display as time
ADDENDUM
Of course, you don't need interp1 to simply scale the existing axis limits; that was to illustrate if you wanted to change those limits to some other range; the axis tick labels are not related to the tick values explicitly, they can be whatever you choose, they just are associated with the tick position.
If you're satisfied with limits and number of ticks, then simply use
du=seconds(hAx.ZTick);
  댓글 수: 2
Richard Youden
Richard Youden 2018년 7월 11일
Thanks for your help. I'll give it a go as soon as some of our Statistics Toolboxes have been released on our network license...
dpb
dpb 2018년 7월 11일
OK, will be interested to see how this works...I made a small fixup to the above Answer.

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

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by