Is it possible to add an 'other' bar to a PARETO plot in MATLAB 7.8 (R2009a)?
조회 수: 1 (최근 30일)
이전 댓글 표시
Currently PARETO will always plot data in descending order as shown in the following plot:
codelines = [200 120 555 608 1024 101 57 687,5000];
coders = ...
{'Fred','Ginger','Norman','Max','Julia','Wally','Heidi','Pat','Other'};
H = pareto(codelines, coders)
title('Lines of Code by Programmer')
I would like to create a PARETO plot with an 'other' category so that even if 'other' is greater than all other categories, it will be plotted last rather than first.
채택된 답변
MathWorks Support Team
2009년 6월 27일
The ability to use PARETO with an 'other' category is not possible in MATLAB 7.8 (R2009a).
As a workaround, you may be able to alter the code for the PARETO function. Please open pareto.m by typing 'edit pareto.m' at the Command Prompt. Then, make the following changes at the given locations:
On Lines 51-57:
for p=1:size(names,1)
if strcmp(names(size(names,1)+1-p,1:5),'Other')
% names=[names(1:p-1,:);names(p+1:size(names,1),:);names(p,:)];
yy=[yy(1:p-1);yy(p+1:length(yy));yy(p)];
ndx=[ndx(1:p-1);ndx(p+1:size(ndx,1));ndx(p)];
end
end
The above takes care of making sure the 'Other' category will come last.
On Lines 76-79:
% k = min(find(cumsum(yy)/ysum>.95,1),10);
%
% if isempty(k), k = min(length(y),10); end
k=length(y);
The above code takes care of the tail end. If we cut on 95% variability the 'Other' categories will not be included in the chart.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!