How to change the legend color?

170 vues (au cours des 30 derniers jours)
Myo Gyi
Myo Gyi le 8 Oct 2019
Commenté : Star Strider le 8 Oct 2019
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')

Réponse acceptée

Star Strider
Star Strider le 8 Oct 2019
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 commentaires
Myo Gyi
Myo Gyi le 8 Oct 2019
Thank You Sir....No problem for this color...But I want to try for the best... Thanks a lot sir
Star Strider
Star Strider le 8 Oct 2019
My pleasure.
If my Answer helped you solve your problem, please Accept it!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Contour Plots 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!

Translated by