Multiple Bars in a single plot along legend

17 ビュー (過去 30 日間)
Usman Mussadiq
Usman Mussadiq 2020 年 4 月 9 日
コメント済み: Ameer Hamza 2020 年 4 月 9 日
First of all, sorry, i am new one here, i do not know how to draw that plot whether it is too basic.
My Question is that
I have 5 users (on X-axis), Capacity(kW)/Cost(PKR) on Y-axis.
Capacity is further classified into Solar as well as storage. its range from 0-14
Three bar lines for each user.
Need Different colors for each Y axis element.
add legend also
Please help me.


Ameer Hamza
Ameer Hamza 2020 年 4 月 9 日
編集済み: Ameer Hamza 2020 年 4 月 9 日
try this
data = [1 2 1 3 2;
2 3 1 2 3;
3 2 1 2 1];
ax = axes();
bar(data', 'stacked')
ax.XTickLabel = {'user1', 'user2', 'user3', 'user4', 'user5'};
legend({'class1', 'class2', 'class3'});
  4 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 9 日
Glad to be of help.


その他の回答 (0 件)


Find more on Polar Plots in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by