how to make horizontal bar graph in matlab?

조회 수: 3 (최근 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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by