help with formatting the title of a set of graphs

7 vues (au cours des 30 derniers jours)
Teshan Rezel
Teshan Rezel le 12 Sep 2022
Commenté : Star Strider le 12 Sep 2022
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!

Réponse acceptée

Star Strider
Star Strider le 12 Sep 2022
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 commentaires
Star Strider
Star Strider le 12 Sep 2022
As always, my pleasure!
Star Strider
Star Strider le 12 Sep 2022
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.
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by