필터 지우기
필터 지우기

How to change the legend color?

조회 수: 112 (최근 30일)
Myo Gyi
Myo Gyi 2019년 10월 8일
댓글: Star Strider 2019년 10월 8일
n = 2/3;
A = 1;
r = linspace(0,0.4,30);
th = linspace(0,2*pi,100);
[R, TH] = meshgrid(r,th);
fi = A*R.^n.*cos(n*TH);
zi = A*R.^n.*sin(n*TH);
[X,Y] = pol2cart(TH,R);
contour(X,Y,fi,'r')
hold on
contour(X,Y,zi,'b')
hold off
xlabel x-axis
ylabel y-axis
title('n = 2/3: flow around a right corner')
legend('\phi','\psi')

채택된 답변

Star Strider
Star Strider 2019년 10월 8일
First, create a handle to the legend object, then change whatever properties you want using the options in Legend Properties.
Example (with your code) —
n = 2/3;
A = 1;
r = linspace(0,0.4,30);
th = linspace(0,2*pi,100);
[R, TH] = meshgrid(r,th);
fi = A*R.^n.*cos(n*TH);
zi = A*R.^n.*sin(n*TH);
[X,Y] = pol2cart(TH,R);
contour(X,Y,fi,'r')
hold on
contour(X,Y,zi,'b')
hold off
xlabel x-axis
ylabel y-axis
title('n = 2/3: flow around a right corner')
hl = legend('\phi','\psi');
set(hl, 'TextColor','r', 'Color','g', 'EdgeColor','b')
Experiment to get the result you want.
  댓글 수: 6
Myo Gyi
Myo Gyi 2019년 10월 8일
Thank You Sir....No problem for this color...But I want to try for the best... Thanks a lot sir
Star Strider
Star Strider 2019년 10월 8일
My pleasure.
If my Answer helped you solve your problem, please Accept it!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by