In a Matlab plot I define my x-axis as a preaccumulated array timeInSec
:
y = data;
x = timeInSec;
plot(x , y);
The generated x-axis on the plot looks like this:
The ticks and tick-values (the 0
, 0.5
, 1
, 1.5
, 2
and 2.5
) here are auto-generated by Matlab. And I am happy with them.
But now I would like to change the tick-value labels customly. Something like:
timeInHrMin = datestr(tickValues, 'HH:MM')
xticklabels(timeInHrMin)
But how do I grab all shown tickValues
? I need them to remain auto-generated. So I must in some way grab only those shown (the 0
, 0.5
, 1
, 1.5
, 2
and 2.5
) and relabel them with xticklabels
.
Is this possible?