The colors displayed in the legend do not match the plot colors.
1 回表示 (過去 30 日間)
古いコメントを表示
This is my code,
colors = ['r';'m';'b';'g';'c'];
symbols = ['*-';'+-';'*-';'+-';'*-'];
for k1 = 1:5
colsym = [colors(k1),symbols(k1,1:2)];
plot(x, y, colsym)
hold on
end
legend('-0.02','-0.01','0','0.01','0.02')
Thanks in advance.
0 件のコメント
回答 (1 件)
Mischa Kim
2014 年 6 月 23 日
編集済み: Mischa Kim
2014 年 6 月 23 日
Hello Priya, not sure how you have defined your y, so check out the code below:
xCenter = 0;
yCenter = 0;
theta = 0 : 0.01 : 2*pi;
colors = ['r';'m';'b';'g';'c'];
symbols = ['*-';'+-';'*-';'+-';'*-'];
for k1 = 1:5
xRadius = k1;
yRadius = 5/k1;
x = xRadius * cos(theta) + xCenter;
y = yRadius * sin(theta) + yCenter;
colsym = [colors(k1),symbols(k1,1:2)];
plot(x, y, colsym)
hold on
end
legend('-0.02','-0.01','0','0.01','0.02')
3 件のコメント
Mischa Kim
2014 年 6 月 23 日
編集済み: Mischa Kim
2014 年 6 月 23 日
See updated code above. The four lines succeeding the for command need to/can be adapted/moved.
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!