help with formatting the title of a set of graphs

7 ビュー (過去 30 日間)
Teshan Rezel
Teshan Rezel 2022 年 9 月 12 日
コメント済み: Star Strider 2022 年 9 月 12 日
Hi folks,
I have a set of graph which look like the attached image. Is there any way to format the title such that it doesn't appear across so many vertical lines? I would like to make the title extend to the width from one set of y axes to the other!
My code to generate the graphs is as follows:
figure;
hold on;
yyaxis left;
plot(temperature, myArea);
xlabel("Temperature (^{o}C)", "FontWeight", "bold");
ylabel("Area (%)", "FontWeight", "bold");
yyaxis right;
plot(temperature, gradArea);
ylabel("\Delta Area (%)", "FontWeight", "bold");
title(['Area and \Delta Area versus Temperature in ' runType ' Atmosphere for ' samples(i)], "FontWeight", "bold");
xlim([600 1500])
hold off;
Thanks!

採用された回答

Star Strider
Star Strider 2022 年 9 月 12 日
Using the sprintf function is one option —
i = 1;
runType = 'Reducing';
samples{1} = 'AK STEEL';
title(sprintf('Area and \\Delta Area versus Temperature in \n%s Atmosphere for %s', runType, samples{i}), "FontWeight", "bold");
I inserted a carriage return-linefeed ('\n') for display purposes. Eliminmate it if necessary.
.
  3 件のコメント
Star Strider
Star Strider 2022 年 9 月 12 日
As always, my pleasure!
Star Strider
Star Strider 2022 年 9 月 12 日
No worries, and no apologies necessary!
I put a ‘newline’ ('\n') character here:
title(sprintf('Area and \\Delta Area versus Temperature in \n%s Atmosphere for %s', runType, samples{i}), "FontWeight", "bold");
↑ ← HERE
to break the line there. Change its position and add more of them if desired.
See the Text Before or After Formatting Operators (there is no direct link to it) section in the documentation section on formatSpec for more information on those and other options.
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by