Help with creating a different type of pareto chart?
11 次查看(过去 30 天)
显示 更早的评论
Hello,
I am wanting to create a pareto chart, but the standard chart that matlab creates is not exactly what I am looking for. I am looking to have a pareto chart that displays on the x-axis a histogram of the distribution, but then just simply displays the summed pareto line counting the percentage of data from left to right.
I can create an example of what I mean in excel using pivot tables, and manually creating a combo chart.
Assume the data I have is:
Y=[ 81 15 21 38 38 21 31 27 22 135 55 24 54 66 97 11 117 332 140 34 456 484 39 12 63 58 52 100 43 16 31 163 173 182 80 216 64 24 27 57 13 589 57 23 31 40 19 37 57 10 57 31 97 95 102 14 178 202 130 12 14 41 37 91 199]
If I run in Matlab pareto(Y), the image I get is the following:
However, this is not exactly what I want. I can show an example of how I'd like it to look using excel. You can see here, the first column is the same data from the variable above Y, however it is only the UNIQUE values. The second column is the count of each occurrence(distribution). The third column is the running total of the count as a percentage of the grand total of items in Y.
The graph plotted is simply a combo chart, with a distribution of the first two columns, and the pareto line is simply the running total plotted on the right side secondary axis. The image of that is here:
SO is there any easy way to accomplish this? I would like to keep the chart in ascending order in the way the excel image I have is.
Also, is there a way to bin this up if necessary, I.e., if I wanted to group values together to have a wider bin size?
0 个评论
采纳的回答
JESUS DAVID ARIZA ROYETH
2019-12-6
Y=[ 81 15 21 38 38 21 31 27 22 135 55 24 54 66 97 11 117 332 140 34 456 484 39 12 63 58 52 100 43 16 31 163 173 182 80 216 64 24 27 57 13 589 57 23 31 40 19 37 57 10 57 31 97 95 102 14 178 202 130 12 14 41 37 91 199];
[s,~,idx]=unique(Y);
y= accumarray(idx,1);
figure;
bar(categorical(s),y);
hold on
plot(cumsum(y)/numel(Y),'r','LineWidth',4)
hold off
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!