Putting plot title one only one line
49 ビュー (過去 30 日間)
古いコメントを表示
I am trying to run the following code:
t = datetime(2006, 01, 01):calmonths(1):datetime(2100, 12, 01);
x = 1:100;
y = 1:100;
for i = 1:12
subplot(6,2,i)
plot(x*i,y)
title(['It is ' month(t(i), 'name')])
end
But the title is forced onto a second line, does anyone know how to keep it on only one line?
0 件のコメント
回答 (1 件)
Star Strider
2017 年 3 月 28 日
With a couple of tweaks, your code works as you want it to:
t = datetime(2006, 01, 01):calmonths(1):datetime(2100, 12, 01);
x = 1:100;
y = 1:100;
for i = 1:12
subplot(6,2,i)
plot(x*i,y)
m = month(t(i),'name'); % Isolate Month Name
title(sprintf('It is %s', m{:})) % Use ‘sprintf’
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!