How to change the legend color?
122 ビュー (過去 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')
0 件のコメント
採用された回答
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 件のコメント
Star Strider
2019 年 10 月 8 日
My pleasure.
If my Answer helped you solve your problem, please Accept it!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!