How can I plot an histogram?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Chiara Scarpellini
el 12 de Sept. de 2021
Editada: Star Strider
el 12 de Sept. de 2021
I need to plot an histogram with these values:
number_of_events=[30.60, 32.30, 32.30, 32.30, 32.30, 2.60, 12.60, 32.30, 32.30, 9.70, 25, 13.20, 18.10, 32.30, 2.50, 32.30]
I don't know why this is not working
number_of_events=number_of_events
figure
histogram(number_of_events,16)
ylim([0 35])
ylabel('Number of events per year')
xticks('27CRA01','23ARV00','29CRD99','28XRA01','15ART03','08BRS01','26ARB01','34XRJ01','34XRI01','00LYF01','31ARA01','05BRM01','29BRL99','34XRH01','20ARB01','00OR100')
title('Times CSOs discharge per year')
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Sept. de 2021
Editada: Star Strider
el 12 de Sept. de 2021
Try something like this —
number_of_events=[30.60, 32.30, 32.30, 32.30, 32.30, 2.60, 12.60, 32.30, 32.30, 9.70, 25, 13.20, 18.10, 32.30, 2.50, 32.30];
number_of_events=number_of_events;
figure
hh = histogram(number_of_events,16);
BinCtrs = hh.BinEdges(1:end-1) + mean(diff(hh.BinEdges))/2;
ylim([0 35])
ylabel('Number of events per year')
xtickc = {'27CRA01','23ARV00','29CRD99','28XRA01','15ART03','08BRS01','26ARB01','34XRJ01','34XRI01','00LYF01','31ARA01','05BRM01','29BRL99','34XRH01','20ARB01','00OR100'};
set(gca, 'XTick',BinCtrs, 'XTickLabel',xtickc)
title('Times CSOs discharge per year')
Experiment to get different results.
number_of_events=[30.60, 32.30, 32.30, 32.30, 32.30, 2.60, 12.60, 32.30, 32.30, 9.70, 25, 13.20, 18.10, 32.30, 2.50, 32.30];
number_of_events=number_of_events;
figure
hb = bar(number_of_events);
% BinCtrs = hh.BinEdges(1:end-1) + mean(diff(hh.BinEdges))/2;
ylim([0 35])
ylabel('Number of events per year')
xtickc = {'27CRA01','23ARV00','29CRD99','28XRA01','15ART03','08BRS01','26ARB01','34XRJ01','34XRI01','00LYF01','31ARA01','05BRM01','29BRL99','34XRH01','20ARB01','00OR100'};
set(gca, 'XTick',hb.XData, 'XTickLabel',xtickc)
title('Times CSOs discharge per year')
Experiment to get different results.
.
0 comentarios
Más respuestas (1)
Sulaymon Eshkabilov
el 12 de Sept. de 2021
there is an err in your code. Here is the corrected one:
number_of_events=[30.60, 32.30, 32.30, 32.30, 32.30, 2.60, 12.60, 32.30,32.30, 9.70, 25, 13.20, 18.10, 32.30, 2.50, 32.30];
histogram(number_of_events,16)
ylim([0 35])
ylabel('Number of events per year')
xticklabels({'27CRA01','23ARV00','29CRD99','28XRA01','15ART03','08BRS01','26ARB01','34XRJ01','34XRI01','00LYF01','31ARA01','05BRM01','29BRL99','34XRH01','20ARB01','00OR100'})
xtickangle(45)
title('Times CSOs discharge per year')
0 comentarios
Ver también
Categorías
Más información sobre Histograms 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!