Histogram of joint probability distribution

Hi, I would like to ask how is it possible to plot a 3D histogram (chart type in excel = 3-D column) based on a joint probability table?
for instance,
gender
jan feb mar apr
male 0.05 0.15 0.025 0.375
female 0.125 0.075 0.05 0.15
I've searched through hist3. but it seems that we need to have the inputs of X, Y, Z, which appear to be in the same length.
in this case, what shall be the inputs to plot a 3D histogram? Thanks in advance.

 채택된 답변

Oleg Komarov
Oleg Komarov 2012년 5월 31일

1 개 추천

You already have calculated the probabilities thus you have to use bar3() instead of hist3() (which is used when you still have to count)
X = [0.05 0.15 0.025 0.375
0.125 0.075 0.05 0.15]
h = bar3(X');
Some additional embelishments
% Set labels
set(gca,'XtickL',{'male','female'},'YtickL',{'jan','feb','mar','apr'})
% Change colors
colormap cool
% Set transaprency
set(h(1),'facea',.5)

댓글 수: 1

Lee ZY
Lee ZY 2012년 6월 1일
Thank you so much Oleg! Didn't know it can be implemented in such a way.
Thanks again and nice day!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

태그

질문:

2012년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by