If you’ve ever wished for an easy way to add a custom analysis to Minitab’s interface, read on! Minitab’s new Python integration feature allows an avenue for easily running custom Python code via a button in the Minitab interface. If you’re not a programmer, fear not! I’m no programmer myself, so if I can do this, you can too.
In this post, I’ll walk through the steps to add a custom menu with a button to execute a Python script that will generate a QQ plot and display the results in Minitab’s output pane.
If you’re a coding wizard, this example is very simple but will give you a feel for how easily you could set up something similar for others in your organization, allowing them take advantage of your custom code. You’ll be a hero!
This feature is available starting with Minitab 19.2020.1, and you’ll need Python 3.6.1 or higher installed on your machine. You can find all the details about connecting Minitab to Python here.
The Python script to generate the QQ plot, along with the necessary commands to send your data from Minitab to Python and return the results to Minitab are shown below:
You can also download the Python script above from here. I found the script to generate the QQ plot by searching the internet, which is easy to do for anyone that doesn’t want to learn to code. Note that the above code will retrieve the data for the QQ plot for column C1 in your Minitab worksheet.
We’ll start by telling Minitab where to find your Python script, using this menu path: File > Options. In the new window, browse to the Default file location where you saved the script. Minitab will look for your Python script in the folder you specify.
Are you still with me? Nice work! You’re almost there!
Now, open a new Windows notepad file and type in the following commands:
PYSC "QQ_plot.py"
This PYSC command tells Minitab to call Python, and to run the QQ plot script. PYSC is the Minitab command, and the value between the double-quotes is the name of the script you want to execute.
To save the commands in the Minitab exec, save the text file and title it QQ_Plot.MTB (be sure to save it with .MTB and not .txt). Save the file to the Default file location where the Python script is saved (the same location you set in Minitab using File > Options):
Excellent job! Next, we’ll create a command to run a Minitab exec file.
Fantastic! Are you still with me, and are you ready to see the results?
After adding some data to the Minitab worksheet (in column C1 if you’re using the script shared in this post), click the QQ Plot C1 button you created in your custom menu on the right, Python Scripts:
Minitab will send your data to Python, then Python will execute the code and send the graph back to the Minitab output pane:
Way to go! Minitab’s new Python integration feature and free open-source code make it easy for people like us, that may want access to some extra features but aren’t particularly interested in learning to code.
And if you haven’t yet tried Minitab 19.2020.1, get your free 30-day trial today!