help with formatting the title of a set of graphs

6 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Star Strider
Star Strider il 12 Set 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 Commenti
Star Strider
Star Strider il 12 Set 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.
.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by