how to make horizontal bar graph in matlab?

2 ビュー (過去 30 日間)
Muhammad Tarique
Muhammad Tarique 2022 年 7 月 5 日
コメント済み: Muhammad Tarique 2022 年 7 月 5 日
I want to make this type of bar graph in Matlab I have made this in excel but its quality is not good please help me out I have spent hours but no success, use following data
rbio3.9 0.02842
bior5.5 0.03022
rbio2.6 0.03026
rbio3.7 0.0306
rbio2.8 0.03075
rbio2.4 0.03107
rbio3.5 0.03385
rbio1.5 0.03403
rbio1.3 0.03482
fk6 0.03695
rbio3.5 0.1064
rbio3.7 0.1069
rbio3.9 0.1084
rbio3.3 0.1113
bior5.5 0.113
rbio1.3 0.1165
rbio2.8 0.1189
db4 0.1217
rbio1.5 0.1231
rbio2.6 0.1246

採用された回答

Chunru
Chunru 2022 年 7 月 5 日
編集済み: Chunru 2022 年 7 月 5 日
a = readtable('data.txt'); % Read the data
a
a = 21×2 table
Var1 Var2 ___________ _______ {'rbio3.9'} 0.02842 {'bior5.5'} 0.03022 {'rbio2.6'} 0.03026 {'rbio3.7'} 0.0306 {'rbio2.8'} 0.03075 {'rbio2.4'} 0.03107 {'rbio3.5'} 0.03385 {'rbio1.5'} 0.03403 {'rbio1.3'} 0.03482 {'---' } NaN {'fk6' } 0.03695 {'rbio3.5'} 0.1064 {'rbio3.7'} 0.1069 {'rbio3.9'} 0.1084 {'rbio3.3'} 0.1113 {'bior5.5'} 0.113
n = height(a);
barh(1:10, a.Var2(1:10));
hold on
barh(11:n, a.Var2(11:n));
h = gca;
h.YTick = 1:height(a);
h.YTickLabel = a.Var1;
legend('Current', 'Voltage', 'Location', 'best')
  3 件のコメント
Chunru
Chunru 2022 年 7 月 5 日
See above.
Muhammad Tarique
Muhammad Tarique 2022 年 7 月 5 日
thank you very much

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

その他の回答 (1 件)

Kausthub Thekke Madathil
Kausthub Thekke Madathil 2022 年 7 月 5 日
You can plot a horizontal bar graph using barh(). I am attaching a refernce link to Horizontal Bar Graph documentation.
Hope it helps

Community Treasure Hunt

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

Start Hunting!

Translated by