How do I overlay the cumulative distribution of some data over a histogram of the same data? I have the following code:
DistributionData=Results(end,:);
figure(4)
clf
nbins = 100;
hist(DistributionData,nbins)
hold on
cdfplot(DistributionData)
hold off
But because the cdf is on a different scale I need to have that on a second y-axis. Ideally I want to plot the inverse cdf also.
Does this work for you?
a = randn(1000,1);
f = figure;
a1 = axes('Parent',f);
hist(a)
a2 = axes('Parent',f);
cdfplot(a)
grid off
set(a2,'Color','none')
set(a2,'YAxisLocation','right')
It's not perfect (for example, the tick marks on right and left axes are superimposed), and I haven't tidied up the title and axis labels, but perhaps that's a good start.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments