How to plot a histogram in 2D if one has the counts already?

15 ビュー (過去 30 日間)
Brando Miranda
Brando Miranda 2017 年 12 月 14 日
コメント済み: Steven Lord 2017 年 12 月 14 日
I collected some 2D histcounts with
histcounts2
now that I have the counts, how do I plot them? I know one can just feed the actual data X to hist3 but unfortunately that is not an feasible option because I suspect it would make matlab crash. I essential pre-compute the histogram counts for my data first because its more memory efficient (or at least doesn't crash matlab).
For a snippet of my code:
Xedges = linspace(lb,ub,nbins);
Y_edges = linspace(lb,ub,nbins);
W_hist_counts_all = zeros( size(nbins,nbins) );
index = 1;
for file_struct = data_filenames'
if ~( strcmp(file_struct.name,'.') || strcmp(file_struct.name,'..') || strcmp(file_struct.name,'.DS_Store') )
load( [path file_struct.name] );
w1 = W_history(:,1);
w2 = W_history(:,2);
current_W_hist_counts = histcounts2(w1,w2,Xedges,Yedges);
W_hist_counts_all = W_hist_counts_all + current_W_hist_counts;
then I just wish to plot:
W_hist_counts_all
any ideas how?

採用された回答

Steven Lord
Steven Lord 2017 年 12 月 14 日
If you're using release R2016b or later, you can "Create a histogram from precomputed bin counts". The specific signature you want is histogram2('XBinEdges',Xedges,'YBinEdges',Yedges,'BinCounts',counts)
  4 件のコメント
Brando Miranda
Brando Miranda 2017 年 12 月 14 日
thanks! I will. My complaint was on histcounts2 not histogram2 though.
Steven Lord
Steven Lord 2017 年 12 月 14 日
Perhaps I'm not understanding your complaint, but the whole purpose of histcounts2 is to compute the bin counts. If you already have the bin counts, you don't need to call histcounts2 at all.
It would be like sending your friend a text message complaining that you have to find your cell phone ... using your cell phone.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by