How to get rid of the date on a plot over time?

17 次查看(过去 30 天)
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

采纳的回答

dpb
dpb 2018-5-17
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 个评论
Michael Steinbuechler
Works like a charm! Thank you very much.
I just realized that changing the date format the way I did it before, doesn't affect the outcome at all.
dpb
dpb 2018-5-17
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 :) ).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by