How can I change 'y axis' into 'Probability', not the 'number' when I use 'hist(variable)' ?

조회 수: 6 (최근 30일)
Figure 1 is what I get from hist(variable);
Figure 2 is what I want to get;
Figure 3 is what I want to to get as well.
  댓글 수: 5
wenhao yang
wenhao yang 2021년 3월 2일
So can you offer me some example on how to write the command to get something like Figure 3 ?
Walter Roberson
Walter Roberson 2021년 3월 2일
h = histfit(___) returns a vector of handles h, where h(1) is the handle to the histogram and h(2) is the handle to the density curve.
So you could set the 'Normalization' option of h(1) to change how the axes got labeled. It is possible that you will need to rescale the curve on h(2) as well.

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

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 2일
편집: KALYAN ACHARJYA 2021년 3월 2일
Is there any sense? Let's suppose I have the following array
> data
data =
4 3 5 3 5 5 3 4 3 5 2 5 2 1 4 5 5 2 5 3
Now the bins and counts as follows
bins: 1 2 3 4 5
counts: 1 3 5 3 8
If you plot the hist of the data, no issue
Once you wish to reverse bar plot, then issue arrise with random data, which is not unique (It suppose to be unique for variable data). However you can get the line plot in this case
[counts,bins]=hist(data);
plot(counts,bins);
Counts data in the variable axes have two issue.
  • Non unique data
  • No linear order (Incresing or Decreasing)
Although you can do other ways to plot the histogram appearance, like barh etc.
Hope it Helps! :)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by