help with formatting the title of a set of graphs

7 visualizaciones (últimos 30 días)
Teshan Rezel
Teshan Rezel el 12 de Sept. de 2022
Comentada: Star Strider el 12 de Sept. de 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!

Respuesta aceptada

Star Strider
Star Strider el 12 de Sept. de 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 comentarios
Star Strider
Star Strider el 12 de Sept. de 2022
As always, my pleasure!
Star Strider
Star Strider el 12 de Sept. de 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.
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by