% Pareto Chart for Quality Control

% Define the data defects = {'Scratches', 'Dents', 'Cracks', 'Chips', 'Discolorations'}; counts = [20, 15, 10, 5, 2];

% Calculate the cumulative percentage total = sum(counts); percentages = 100 * counts / total; cumulativePercentages = cumsum(percentages);

% Create the Pareto Chart figure; bar(percentages, 'b'); hold on; plot(cumulativePercentages, 'r-o');

% Set the chart properties xlabel('Defects'); ylabel('Percentage'); title('Pareto Chart for Quality Control'); legend('Percentage', 'Cumulative Percentage', 'Location', 'NorthWest');

% Add the defect labels and percentage values xticks(1:length(defects)); xticklabels(defects); yticks(0:10:100); for i = 1:length(defects) text(i-0.2, percentages(i)+2, [num2str(percentages(i)), '%']); end

% Add the cumulative percentage values for i = 1:length(defects) text(i-0.2, cumulativePercentages(i)+2, [num2str(cumulativePercentages(i)), '%']); end

% Adjust the axis limits ylim([0, 110])

write a matlab code to draw a example of Pareto Chart for Quality Control

原文地址: https://www.cveoy.top/t/topic/cJyz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录