How to get rid of the date on a plot over time?
16 views (last 30 days)
Show older comments
Hello Matlab-Pros,
I want to plot values over time, but I matlab always adds the day to the axis description.
How can I get rid of this date?
That's my (very easy) code:
x = (linspace(StartT,EndT,IndexFinalDepth));
x.Format = 'HH:mm:ss';
y = (-1)*(RawData(1:IndexFinalDepth,1));
TimePlot = subplot(ax1);
plot(x,y)
ylim ([(-maxDepth-2) 0]);
xlim auto
ylabel('Elevation [m]','FontSize',7)
set(gca,'fontsize',7)
TimePlot.Title.String = 'Depth Profile';
TimePlot.Title.FontWeight = 'normal';
TimePlot.Title.FontSize = 7;
Thanks in advance!
Mike
0 Comments
Accepted Answer
dpb
on 17 May 2018
Can't by just using the format string for the datetime ruler object; it will put whatever is needed to make the date labels unique. You can, however, write the XTickLabel property and that overrides the XTick display...
TimePlot = subplot(ax1);
plot(x,y)
x.Format='HH:mm';
TimePlot.XTickLabel=cellstr(x);
....
>>
2 Comments
dpb
on 17 May 2018
That's correct; that only affects the display of the object; you can change the format of the axis time ruler with the xtickformat function or the '.TickLabelFormat' property, but the datetime ruler has a mind of its own regarding that it thinks it must somehow make the times shown unambiguous despite what you tell it you want.
Only writing specifically the text in the label property that isn't tied to the tick value overrides that "feature". I had fairly long conversation with a TMW staffer a few weeks ago on the subject and suggested that be made user-settable (whether will take the advice is anybody's guess :) ).
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!