Help with creating a different type of pareto chart?

11 ビュー (過去 30 日間)
Forrest
Forrest 2019 年 12 月 6 日
コメント済み: Forrest 2019 年 12 月 6 日
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?

採用された回答

JESUS DAVID ARIZA ROYETH
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
  1 件のコメント
Forrest
Forrest 2019 年 12 月 6 日
Thank you!
I managed to stumble upon "yyaxis right" that will plot the cumsum on the secondary axis and gives me a display that is a bit easier to interpret also!
[s,~,idx]=unique(Y);
y= accumarray(idx,1);
figure;
bar(categorical(s),y);
hold on
yyaxis right
plot(cumsum(y)/numel(Y),'r','LineWidth',4)
hold off
1.jpg
2.jpg

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by