Creating a histogram with non-increasing x axis

6 ビュー (過去 30 日間)
Tom Field
Tom Field 2024 年 9 月 20 日
回答済み: KSSV 2024 年 9 月 20 日
Hi there,
I am attempting to make a histogram for occurence throughout the year, and I would like to have my plot centered on month 12 as to enhance readability. Is there anyway to do this as a Histogram or do I have to turn it into a bar graph and then manually reorder. I have not included my code as it is rather long, but let me know if it is needed.
Thanks in advance.

採用された回答

KSSV
KSSV 2024 年 9 月 20 日
A = rand(100,1) ;
figure
h = histogram(A) ;
vals = h.Values ;
bins = h.BinEdges ;
bins = (bins(1:end-1)+bins(2:end))/2 ;
% Arrange the bins in your required order
idx = [4 1 3 2 5] ;
figure
bar(vals(idx))
str = cellstr(string(bins(idx))) ;
xticklabels(str)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by