The following are answers to some of the most common questions users have about graphs in macros. For complete guidance on creating and running macros, see Minitab Macros Help.

What is the number coding scheme for colors/symbols/line types?

Minitab Help contains topics documenting the various codes. You can find these topics in Minitab Session Command Help. Look for the following topics in the PDF document:
  • Numbers for colors to use in session commands
  • Numbers for fill types to use in session commands
  • Numbers for line types to use in session commands
  • Numbers to use for symbols and markers in session commands

Using commands, how can I save a Minitab graph as a JPEG, PNG, TIF, or Windows BMP file?

Create the graph using the session command, the GSAVE subcommand, and the applicable graphics format subcommand. For example, suppose you want to create a histogram of column C1 and save the graph as a JPEG in the root of your C: drive with the filename Defects. Use the following commands:

HIST C1;
GSAVE "C:\Defects";
JPEG.
Note

The default graph file is saved as a PNG (Portable Network Graphics), which is the PNGC subcommand. For TIFF (Tagged Image File Format), use the subcommand TIFC. For Windows BMP (Windows Bitmap), use BMPC.

Note

In a macro, you may see GSAVE used in other commands, such as CALL. The graphics format subcommand mentioned here, such as JPEG, should not be inserted in such cases.

How do I print a graph from the macro I wrote?

In Minitab 19 and higher, you cannot use a macro to send any output to a physical printer.

How can I use today's date (or today's date and time) as a footnote on the graph I'm creating with a local macro?

For example, suppose you want to put the current date as a footnote on a histogram of a column called YIELD.

Note

The steps below assume that columns called YIELD and TMPDATE, and a constant called DATE are listed in the declaration section of the local macro, and that the column YIELD contains data.

  1. Use the TODAY() function to store the current date in a column:
    LET TMPDATE = TODAY()
    Note

    If you want the current date and time on the graph, use NOW() instead of TODAY().

  2. Change the data type so the column is formatted as a text column:
    TEXT TMPDATE TMPDATE
  3. Store the date as a constant:
    LET DATE = TMPDATE
  4. Use the constant in the FOOTNOTE subcommand:
    HIST YIELD;
    FOOTNOTE DATE.

How can I write my macro so that I control pausing after graphs are created?

Minitab 19 and higher does not provide this capability.

Is there a Session command to close the last graph or all graphs?

Minitab 19 and higher does not provide this capability. To close individual output tabs, click the x on the tab. To delete an individual graph from inside of an output pane, right click the graph and choose Delete. You can reopen a closed tab, but you can not undelete a graph.

How to use subcommands such as GSAVE and WTITLE for graphs that do not include these subcommands

You can use subcommands such as GSAVE and WTITLE for graphs that do not include these subcommands if you also use the LAYOUT command.

Using GSAVE and WTITLE for GSUMMARY

Stat > Basic Statistics > Graphical Summary

Suppose you want to save the Graphical Summary of C1 as a JPEG with the name YIELD.JPG in C:\My Statistics, and you want "San Francisco" to be displayed in the title bar of the graph. Use the following commands:
LAYOUT;
GSAVE "C:\My Statistics\YIELD.JPG";
JPEG;
WTITLE "San Francisco".
GSUMMARY C1
ENDLAYOUT.

Using GSAVE and WTITLE for GageRR

Stat > Quality Tools > Gage Study > Gage R&R Study (Crossed)

Suppose you want to run the following Gage R&R Study (Crossed) command:
GageRR;
Parts 'Part';
Opers 'Operator';
Response 'Measurement';
Studyvar 6.
Suppose you want to save the graph as a JPEG with the name GageRR.JPG in Q:\Project, and you want "Gage 1" to be displayed in the title bar of the graph. Use the following commands:
LAYOUT;
GSAVE "Q:\Project\GageRR.JPG";
JPEG;
WTITLE "Gage 1".

GageRR;
Parts 'Part';
Opers 'Operator';
Response 'Measurement';
Studyvar 6.

ENDLAYOUT.