Is it possible to add an 'other' bar to a PARETO plot in MATLAB 7.8 (R2009a)?

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 27 de Jun. de 2009
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.

Más respuestas (0)

Categorías

Más información sobre Multiobjective Optimization en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by