How can I plot an histogram?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Chiara Scarpellini
am 12 Sep. 2021
Bearbeitet: Star Strider
am 12 Sep. 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 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Sep. 2021
Bearbeitet: Star Strider
am 12 Sep. 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 Kommentare
Weitere Antworten (1)
Sulaymon Eshkabilov
am 12 Sep. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!