Effacer les filtres
Effacer les filtres

how to make horizontal bar graph in matlab?

3 vues (au cours des 30 derniers jours)
Muhammad Tarique
Muhammad Tarique le 5 Juil 2022
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

Réponse acceptée

Chunru
Chunru le 5 Juil 2022
Modifié(e) : Chunru le 5 Juil 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')
  3 commentaires
Chunru
Chunru le 5 Juil 2022
See above.
Muhammad Tarique
Muhammad Tarique le 5 Juil 2022
thank you very much

Connectez-vous pour commenter.

Plus de réponses (1)

Kausthub Thekke Madathil
Kausthub Thekke Madathil le 5 Juil 2022
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