Python for Industrial Engineers
Quality Control Charts with Python
Creating Quality Control Charts using Python libraries

Quality Control Charts
Quality control charts represent a great tool for engineers to monitor if a process is under statistical control. They help visualize variation, find and correct problems when they occur, predict expected ranges of outcomes and analyze patterns of process variation from special or common causes. Quality control charts are often used in Lean Six Sigma projects and DMAIC projects under the control phase and are considered as one of the seven basic quality tools for process improvement.
The appropriate control chart to use is determined by the type of data (i.e. measurement), the number of defects and the sample size. The following decision tree illustrates the conditions for each control chart, respectively:

Control Limits
Control limits are plotted lines above and below the center line (i.e. mean) in quality control charts that function as thresholds to identify signals (i.e. points beyond control limits) and help determining if a process is under statistical control. They are defined by formulas specific to each type of control chart that include constants, which vary depending on the sample size. Such constants are listed in the following table:

For the following examples, each type of quality control chart will be built from scratch using Python. In the same way, a brief description of each control chart will be provided. Let’s take a look at the Python codes.
Control Charts for Continuous Data
x chart and mR chart
The x chart (also known as individual chart) and mR chart are used to monitor the mean and variation of a process based on individual samples taken in a given time. In order to use the mR chart along with the x chart, the sample size n must be equal to 1. On the x chart, the y-axis shows the mean and the control limits while the x-axis shows the sample units. On the mR chart, the y-axis shows the moving range grand mean and the control limits while the x-axis shows the sample units.













