フィルターのクリア

Colors not showing in legend

21 ビュー (過去 30 日間)
Fabrizio Bernardi
Fabrizio Bernardi 2021 年 11 月 19 日
コメント済み: VBBV 2021 年 11 月 19 日
Hello everyone, I am having problems with legends in plots... If I plot several things defining colors and using hold on, once used the legend command I don't see the color references... as example, after the following code:
plot(my_data(zone1,2),my_data(zone1,3),'b')
hold on
plot(my_data(zone2,2),my_data(zone2,3),'r')
plot(my_data(zone3,2),my_data(zone3,3),'g')
plot(my_data(zone4,2),my_data(zone4,3),'y')
plot(my_data(zone5,2),my_data(zone5,3),'c')
plot(my_data(zone6,2),my_data(zone6,3),'k')
legend('zone1','zone2','zone3','zone4','zone5','zone6')
I have the following plot:
Plot is fine and all references are there, but no colors...
Can someone help?
Thank you very much,
Fabrizio

採用された回答

VBBV
VBBV 2021 年 11 月 19 日
legend('Zone1','Zone2','Zone3','Zone4','Zone5','Zone6');
Use a different variable name for legends. It seems you also use it as indices in your plot matrices.
  3 件のコメント
VBBV
VBBV 2021 年 11 月 19 日
編集済み: VBBV 2021 年 11 月 19 日
are you plotting inside a GUI or App?
VBBV
VBBV 2021 年 11 月 19 日
legend({'Zone1','Zone2','Zone3','Zone4','Zone5','Zone6'});
or try using a cell array

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by