how to make horizontal bar graph in matlab?

3 views (last 30 days)
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

Accepted Answer

Chunru
Chunru on 5 Jul 2022
Edited: Chunru on 5 Jul 2022
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')

More Answers (1)

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

Categories

Find more on 2-D and 3-D 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!