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

10 vues (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 5 Mai 2022
Commenté : KSSV le 5 Mai 2022
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

Réponse acceptée

KSSV
KSSV le 5 Mai 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 commentaires
Alberto Acri
Alberto Acri le 5 Mai 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)?
KSSV
KSSV le 5 Mai 2022
Check the number of bins in both the plot.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by