필터 지우기
필터 지우기

Multiple subplots having same legend

조회 수: 2 (최근 30일)
MattC
MattC 2023년 3월 15일
편집: VBBV 2023년 3월 16일
  1. 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?
  2. 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

답변 (1개)

VBBV
VBBV 2023년 3월 15일
Read this page https://in.mathworks.com/help/matlab/ref/sgtitle.html
  댓글 수: 9
MattC
MattC 2023년 3월 16일
Basically, I am trying to add a legend on top of the first subplot which will be generic like has shapes and the corresponding names with some color coding. Not trying to pull anything specific from the subplots. Is it possible then?
VBBV
VBBV 2023년 3월 16일
편집: VBBV 2023년 3월 16일
Legend positioning is possible for subplots using that custom function. Have a look at it. Otherwise you need an extra subplot to display legend something like what @starstrider demonstrated.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by