How to get rid of this warning which point at extra entries?

2 ビュー (過去 30 日間)
Tony Castillo
Tony Castillo 2021 年 9 月 9 日
編集済み: Adam Danz 2021 年 9 月 9 日
Dear all, I want to know why do I receive the following warning if my code is not in a loop?
Warning: Ignoring extra legend entries.
> In legend>process_inputs (line 587)
In legend>make_legend (line 315)
In legend (line 259)
In PVGeo__SCy (line 394)
figure(1)
n=12;
U1=[energy_, (heat_cons + HDW_c)]; %%%Ren
U2=[(Power_ + Sp_ + Lamp_), (heat_cons_ + HDW_c)*SPF]; %%%Consumption
c{1}=deal(U1);
c{2}=deal(U2);
b1= bar(c{1},'stacked');
b1(1).BarWidth = 0.4;
hold on;
b2=bar(c{2},'stacked');
b2(1).BarWidth = 0.9;
b2(1).FaceAlpha = 0.3;
% b2(1).BarWidth, b2(2).BarWidth, b2(3).BarWidth = 0.4;
set(b2, 'BarWidth', 0.9);
xlabel('Months', 'FontWeight','bold')
ylabel('Consumption vs RES (kWp)', 'FontWeight','bold')
grid on
xticklabels(LastName)
% go.Annotation.LegendInformation.IconDisplayStyle = 'on';
labels = {'Electricity consumption' 'Thermal consumption' 'Photovoltaic Generation' 'Geothermal Generation', 'Location', 'bestoutside' };
legend([b2 b1], labels);

採用された回答

Adam Danz
Adam Danz 2021 年 9 月 9 日
編集済み: Adam Danz 2021 年 9 月 9 日
Assuming [b2, b1] produces a vector with 4 handles, try this
legend([b2,b1], labels{:})
or this
labels = {'Electricity consumption' 'Thermal consumption' 'Photovoltaic Generation' 'Geothermal Generation'};
legend([b2 b1], labels, 'Location', 'bestoutside');

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by