how to make horizontal bar graph in matlab?

3 visualizaciones (últimos 30 días)
Muhammad Tarique
Muhammad Tarique el 5 de Jul. de 2022
Comentada: Muhammad Tarique el 5 de Jul. de 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

Respuesta aceptada

Chunru
Chunru el 5 de Jul. de 2022
Editada: Chunru el 5 de Jul. de 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 comentarios
Chunru
Chunru el 5 de Jul. de 2022
See above.
Muhammad Tarique
Muhammad Tarique el 5 de Jul. de 2022
thank you very much

Iniciar sesión para comentar.

Más respuestas (1)

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

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by