I want to create a curve on the histogram?

Hi Guys, first of all I am beginner in Matlab, I did histogram to the data, now I want to create curve on the histogram which I made.
Thank you
Reyadh

1 commentaire

Image Analyst
Image Analyst le 26 Mai 2015
What do you mean? Do you mean like you have a bar chart of the counts and you'd like to superimpose a smooth line/curve plot (like a Gaussian or something) on top of the bar chart?

Connectez-vous pour commenter.

 Réponse acceptée

Thorsten
Thorsten le 26 Mai 2015
Modifié(e) : Thorsten le 26 Mai 2015
If you want to plot something on top of your histogram, use
hold on
plot(your arguments here)
If you want to plot the histogram as a curve, use
H = hist(whatever);
plot(H)

5 commentaires

thanks for your answer but it doesn't work with the code. my code is:
if true
% cd D:\Script\Alhuwaizah_Marsh\Alhuwaizah_1986
H= May_1986(:);
hist(H);
axis([0.0 0.5 0 70])
%hold on
% plot(H)
title('AVHRR NDVI, May 1986, Al-Huwaizah','fontsize',17,'fontweight','bold','fontname','Times New Roman');
xlabel('NDVI','fontsize',14)
ylabel('AVHRR Pixels','fontsize',14)
set(gca,'XMinorTick','on')
set(gca,'YMinorTick','on')
set(gca,'XGrid','on')
set(gca,'YGrid','on')
set(gca,'GridLineStyle',':','linewidth',1)
set(gca,'TickDir','out')
set(gca,'TickLength',[.015 .025])
save('May_Hist_1986.fig');
end
So exactly what do you want to do, and what doesn't work?
Plot histogram
hist(H)
Plot curve on top
hi = hist(H);
hold on
plot(hi)
Hi Thorsten, I did what you told me but didn't appear any curve on the histogram. by the way I attached the fig.
if true
% cd D:\Script\Alhuwaizah_Marsh\Alhuwaizah_1986
H= Oct_1986(:);
hist(H);
hi=hist(H);
hold on
plot(hi)
hold off
title('AVHRR NDVI, Oct 1986, Al-Huwaizah','fontsize',17,'fontweight','bold','fontname','Times New Roman');
xlabel('NDVI','fontsize',14)
ylabel('AVHRR Pixels','fontsize',14)
set(gca,'XMinorTick','on')
set(gca,'YMinorTick','on')
set(gca,'XGrid','on')
set(gca,'YGrid','on')
set(gca,'GridLineStyle',':','linewidth',1)
set(gca,'TickDir','out')
set(gca,'TickLength',[.015 .025])
axis([0.0 0.5 0 70])
save('Oct_Hist_1986.fig');
end
Thorsten
Thorsten le 26 Mai 2015
Modifié(e) : Thorsten le 27 Mai 2015
Try
[hi cx] = hist(H);
plot(cx, hi, 'r', 'LineWidth', 10)
What are the following commands showing you?
subplot(1,2,1), hist(H)
subplot(1,2,2), plot(cx, hi)
reyadh Albarakat
reyadh Albarakat le 26 Mai 2015
Thank you so much Thorsten, I appreciate you efforts.
Reyadh

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by