MATLAB: How to hide the unit shown as x-label in a datetime or duration plot

datetimedurationMATLAB

Hello,
A question regarding the unit shown as label in a datetime/duration plot. How can I hide this unit in the right bottom edge? Background is to manually set the unit in the x-label. So far I couldn't find a parameter in the DatetimeRuler or DurationRuler Object. Here's a minimal working example.
x_data = duration(0,00:10:60,0,'Format','m');
y_data = 1:size(x_data,2);
plot(x_data,y_data);
Thanks for your help

Best Answer

If the use of a DurationRuler is not required in your workflow, one possible workaround is to eliminate the same:
x_data = duration(0,00:10:60,0,'Format','m');
y_data = 1:size(x_data,2);
plot(minutes(x_data),y_data);
The minutes function converts between duration and double values.
Alternately, you can also set the XTickLabelMode property of your axes to 'manual':
x_data = duration(0,00:10:60,0,'Format','m');
y_data = 1:size(x_data,2);
plot(x_data,y_data);
drawnow;
ax=gca;
ax.XTickLabelMode='manual';
Now the unit is not displayed. However, when you zoom into the figure, the x-ticks are updated but their labels are not due to this change. This workaround is useful if your workflow does not require zooming in and out of the figure.