Plotting cumulative frequencies using 'bar' command

2 次查看(过去 30 天)
Hello
I have 2 sets (A and B) of values where length(A) equals length(B)
The distribution of numbers in A and B, range from min(A) to max(A).(min(A) equals min(B) and max(A) equals max(B))
I calculate cumulative frequencies for A and B as below:
[CountsA,BincentersA]=cumsum(hist(A)); [CountsB,BincentersB]=cumsum(hist(B));
Now, I plot a bar chart comparing cumulative frequency distributions of A and B (on X axis, I have BincentersA)
figure;
width1=0.5;
bar(BincentersA,cumsum(hist(A)),width1,'r');
hold on;
width2=width1/2;
bar(BincentersA,cumsum(hist(B)),width2,'b');
I have 2 questions: 1. Is the logic "'cumsum(hist)' comparing with bincenters I got from hist" correct for plotting cumulative frequencies Vs bin centers?
2. I am getting a bar plot with bars spaced little distant from each other. How do I get bars with no space between them (continuous bars along x axis)?
Thanks for the help Harish

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by