Renaming the X-axis in bargraphs

1 回表示 (過去 30 日間)
SANGHAMITRA MISHRA
SANGHAMITRA MISHRA 2018 年 6 月 24 日
コメント済み: SANGHAMITRA MISHRA 2018 年 6 月 24 日
Hi, I have a bar graph that plots the mean square error of 2 algorithms and the graphs looks like below:
However, the X-axis is showing 1 and 2, but I want it to be 'X-coord MSE' and 'Y-coord MSE' respectively. How can I do this?
MSE_algo1 = [2.3788 1.2497];
MSE_algo2 = [2.6255 1.8021];
MSE=[MSE_algo1;MSE_algo2]'
b=bar(MSE);
legend('MSE for algo1', 'MSE for algo2');
ylabel('Mean Square Error');

採用された回答

Rik
Rik 2018 年 6 月 24 日
The code below should work. (note that it is safer to explicitly set the X-tick positions, although that is not necessary in this case)
figure(1),clf(1)
MSE_algo1 = [2.3788 1.2497];
MSE_algo2 = [2.6255 1.8021];
MSE=[MSE_algo1;MSE_algo2]';
b=bar(MSE);
legend('MSE for algo1', 'MSE for algo2');
ylabel('Mean Square Error');
set(gca,'XTick',[1 2])
set(gca,'XTickLabel',{'X-coord MSE','Y-coord MSE'})
  1 件のコメント
SANGHAMITRA MISHRA
SANGHAMITRA MISHRA 2018 年 6 月 24 日
Thank you so much Rik

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by