creating a hist3() plot with already binned data

Hello,
I was wondering if anybody could help me with a relatively simple problem that I have creating a plot. I create a 3D histogram using the code below. It bins the data accordingly and then creates the plot.
My question, if I have the data already binned in a 81x121 matrix, what would the code be to create the plot. I need to skip the hist3() part in a way.
I would be grateful if anybody could advise me how to do so.
Thank you
Regards
J
edges = {-4:0.1:4, 0:120}
hist3(Data,'Edges',edges);
set(gcf,'renderer','opengl');
s = get(gca,'child');
zData = get(s,'zData');
colormap hot;
set(s,...
'zData' ,zData/length(Data),... % normalize frequency
'FaceColor' ,'interp',...
'EdgeColor' ,0.3*[1 1 1],... % make edges visible at all heights
'CDataMode' ,'auto'); % color tops according to height

回答 (2 件)

the cyclist
the cyclist 2013 年 2 月 2 日

0 投票

I think you just need the bar3 command. For example,
>> bar3(magic(5))
This is analogous to using bar() to plot the results of a regular histogram.

4 件のコメント

John
John 2013 年 2 月 2 日
Thanks, I though that would work.
But how would I set the colors on the plot. In the previous method it gets the zdata from the plot and normalizes it. The data is already normalized, I just want to color it in the same way but I'm not sure of the correct syntax.
Thank you
the cyclist
the cyclist 2013 年 2 月 3 日
A = magic(3);
h = bar3(A);
for ii = 1:length(h)
ZData = get(h(ii),'ZData');
set(h(ii), ...
'CData' ,ZData/length(A),...
'FaceColor' ,'interp',...
'EdgeColor' ,0.3*[1 1 1]);
end
John
John 2013 年 2 月 3 日
Thank you
the cyclist
the cyclist 2013 年 2 月 3 日
Please consider accepting this answer if you found it helpful. That may help future users identify solutions to similar questions.

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

Yelena Bagdasarova
Yelena Bagdasarova 2018 年 7 月 16 日
編集済み: Yelena Bagdasarova 2018 年 7 月 16 日

0 投票

On a related note, here's a method to redraw a histogram of binned data using bin edges and counts:
histogram('BinEdges',[1 2 3 4],'BinCounts',[1 2 3],'DisplayStyle', 'stairs')

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

タグ

質問済み:

2013 年 2 月 2 日

編集済み:

2018 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by