Date stamp on plot
1 回表示 (過去 30 日間)
古いコメントを表示
Hello.
I am having an issue where I am plotting data using datetime (converting from excel) and it is giving me the date stamp of the current day on the plot. I need to specify the date I want and stamp it onto the plots without interfering with the data. How can I do this?
Thanks!
2 件のコメント
Scott MacKenzie
2021 年 6 月 10 日
So, you are reading a date and time from Excel into a datetime variable, but the datetime variable is for the current day not the day in the Excel file. It might help if you provide the data and your code.
採用された回答
Star Strider
2021 年 6 月 10 日
編集済み: Star Strider
2021 年 6 月 10 日
The only way I can devise to delete the date is to create new y-tick labels and use them instead —
F = openfig('untitled.fig');
Ax = gca; % Axis Handle
yt = Ax.YTick; % Y-Tick Values
ythm = compose("%02d:%02d", [hour(yt); minute(yt)].') % Create New Ones
Ax.YTickLabel = ythm; % Use Them For The New Y-Ticks
text(min(xlim), max(ylim), 'Your Date Here', 'Vert','bottom', 'Horiz','left')
The new plot —
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/649105/image.png)
EDIT — (10 Jun 2021 at 16:46)
Added text call to insert ‘Your Date Here’ date information.
.
0 件のコメント
その他の回答 (1 件)
Steven Lord
2021 年 6 月 10 日
plot(1:10, 1:10)
title("This plot was created at " + string(datetime('now')))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!