- Control over the spacing between the plots and around the edges of the layout
- An option for a shared title at the top of the layout
- Options for shared x- and y-axis labels
- An option to control whether the tiling has a fixed size or variable size that can reflow
How do I add a title to each subplot?
1 453 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
marie
le 13 Mar 2013
Modifié(e) : MathWorks Support Team
le 23 Mar 2021
I have the following codes
delta=[-2*pi:0.063:2*pi];
y=sin(delta);
subplot(3,2,1)
plot(y)
y=cos(delta);
subplot(3,2,2)
plot(y)
title(sin(delta))
My question is how do i put the title for each graph and labels? i tried to to do title(sin(delta)) but it doesn't show
0 commentaires
Réponse acceptée
Image Analyst
le 13 Mar 2013
Modifié(e) : MathWorks Support Team
le 23 Mar 2021
Starting in R2019b, you can use the tiledlayout and nexttile functions to create a configurable tiling of plots. The configuration options include:
For R2019a and before, put the title commands after the plot and before the next subplot. Specify the title as a character vector or string scalar.
delta=[-2*pi:0.063:2*pi];
y=sin(delta);
subplot(3,2,1)
plot(y)
title('sin(delta)')
y=cos(delta);
subplot(3,2,2)
plot(y)
title('cos(delta)')
0 commentaires
Plus de réponses (2)
Chad Greene
le 28 Avr 2016
For subplots I often prefer to use ntitle rather than title. The difference is ntitle keeps the text closer to the data, whereas title places the text high above the axes, where it may appear to be an xlabel for to the plot above.
0 commentaires
Azzi Abdelmalek
le 13 Mar 2013
title('sin(delta)')
2 commentaires
Shakir Hussain
le 29 Mar 2019
Great Azzi
You are always providing short,simple and effective solution
thankyou for your effort
Chad Greene
le 5 Avr 2019
Or this, which is shorter, simpler, and just as effective :-)
title sin(delta)
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!