How can I hide the unit shown as x-label in a datetime or duration plot?

12 views (last 30 days)
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

Accepted Answer

Amita Amte
Amita Amte on 22 Aug 2017
Edited: Amita Amte on 22 Aug 2017
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.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!