Hist3 axis scale (time)
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
dpb
am 10 Jul. 2018
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...
Antworten (1)
dpb
am 11 Jul. 2018
Bearbeitet: dpb
am 11 Jul. 2018
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 Kommentare
dpb
am 11 Jul. 2018
OK, will be interested to see how this works...I made a small fixup to the above Answer.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!