Plotting a histogram (setting the color) with a fit distribution

1 view (last 30 days)
Hi, I have the histogram on the left.
However, by applying the histfit() command I get the figure on the right.
I would like to return the same histogram on the left to the histogram on the right. How can i do that?
I use these lines of code:
H = histogram(A,'facecolor', [0 1 1], 'facealpha',.1,'edgecolor','k');
histfit(A)
where "A" is a vector of about 10000x1 double

Accepted Answer

KSSV
KSSV on 5 May 2022
H = histogram(A,'facecolor', [0 1 1], 'facealpha',.1,'edgecolor','k');
h = histfit(A) ;
% get the data of hist-fit
x = h(2).XData ;
y = h(2).YData ;
% now you go to the first figure or plot the histogram yoou want like
H = histogram(A,'facecolor', [0 1 1], 'facealpha',.1,'edgecolor','k');
hold on
plot(x,y,'b') % lot the fit curve
  2 Comments
Alberto Acri
Alberto Acri on 5 May 2022
ok thanks for the reply.
I have a doubt: I get a different curve than the one obtained before using only the "histfit" command. How come?
Is it possible to extrapolate in a new figure only the curve (without the histogram)?

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!