Multiple subplots having same legend
Mostrar comentarios más antiguos
- I have 3 subplots in the format (3,1,1),(3,1,2),(3,1,3) and I want to add a common legend on top of these plots. How do I do that?
- How to add a title where I have a string and 3 numeric value I would like to take as input. It prints multiple times with my current code
A = 25
B = 0.02
C = 0.09
D = plaintext(E)% E might contain _ values
title(sprintf('D: %g A=%.2f, B=%.3f, C=%.3f',plaintext(E),A,B,C))
function s = plaintext( s )
s = regexprep( s, '[\\\^\_]','\\$0');
end
Respuestas (1)
VBBV
el 15 de Mzo. de 2023
0 votos
Read this page https://in.mathworks.com/help/matlab/ref/sgtitle.html
9 comentarios
VBBV
el 15 de Mzo. de 2023
sgtitle is needed for making common title for all subplots
A = 25
B = 0.02
C = 0.09
E = '_Hello $World'
D = plaintext(E)% E might contain _ values
title(sprintf('A=%0.2f, B=%.3f, C=%.3f\n D: %s',A,B,C,plaintext(E)))
function s = plaintext( s )
s = strrep( s, '_','0');
end
VBBV
el 15 de Mzo. de 2023
Use %s format specifier for printing strings. strrep for replaicng required text/character patttern from given string
MattC
el 15 de Mzo. de 2023
VBBV
el 15 de Mzo. de 2023
To add common legend you can use sgtitle function. This link will provide more info about how to add a common legend for multiple subplots
MattC
el 15 de Mzo. de 2023
Sorry, i misread first part of your question, To have a common legend, its better to use this custom function in File Exchnage .
I dont know if Matlab has such standard functions to represent a common legend for all subplots.
MattC
el 16 de Mzo. de 2023
Categorías
Más información sobre Legend en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
