How to change the legend color?

130 次查看(过去 30 天)
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 中查找有关 Data Distribution Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by