Hist3 axis scale (time)

3 visualizzazioni (ultimi 30 giorni)
Richard Youden
Richard Youden il 10 Lug 2018
Commentato: dpb il 11 Lug 2018
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 Commento
dpb
dpb il 10 Lug 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...

Accedi per commentare.

Risposte (1)

dpb
dpb il 11 Lug 2018
Modificato: dpb il 11 Lug 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 Commenti
Richard Youden
Richard Youden il 11 Lug 2018
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 il 11 Lug 2018
OK, will be interested to see how this works...I made a small fixup to the above Answer.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by