I am new to JMP and encountering issues exporting multiple box plots. My goal is to create plots with X-axis variables grouped by another parameter. However, the exported output is missing some X-axis data, even though the plots are correct when I use a single specific column.
Here is my code:
//桌面創建資料夾帶上當天日期
timestamp = Format Date(Today(), "ddmmyyyy");
desktop_path = Get Environment Variable("USErProfile") || "$DESKTOP";
folder_path = desktop_path || "/JMP_Analysis_" || timestamp ;
CreateDirectory(folder_path);
// Set the output directory to the newly created folder
outputDir = folder_path || "/";
dt = Open(
"$DESKTOP/file/file.xls",
Worksheets( "Sheet1" ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 2 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
//將導入EXCEL之JMP存檔
dt << Save(outputDir || "Joe_CrazyFileCR.jmp");
// Identify rows corresponding to "Upper Limit" and "Lower Limit"
upperRow = dt << Get Rows Where(:Site == "Upper Limit");
lowerRow = dt << Get Rows Where(:Site == "Lower Limit");
// Ensure valid row indices for limits
If(N Rows(upperRow) == 0 | N Rows(lowerRow) == 0,
Throw("Error: Missing 'Upper Limit' or 'Lower Limit' row in the data.")
);
// Get the first row indices for upper and lower limits
upperRowIndex = upperRow[1];
lowerRowIndex = lowerRow[1];
// Loop through each column
For( i = 4, i <= N Cols( dt ), i++,
// Get column reference and name
col = Column( dt, i );
colName = col << Get Name;
// Retrieve the limit values for the current column
upperLimit = Num(dt[upperRowIndex, i]);
lowerLimit = Num(dt[lowerRowIndex, i]);
// Create a box plot for the column
bp = dt << Graph Builder(
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables(
X( :Vendor1 ),
Y(col), // Box plot for the current column
Group X( :Vendor2 )
),
Elements( Box Plot( Y, Legend( 0 ) ) ),
// Add Reference Lines for Limits
SendToReport(
Dispatch(
{},
colName, // Use the column name to target the Y-axis scale,
ScaleBox,
{Add Ref Line(upperLimit, "Dashed", "Green", "Upper Limit"),
Add Ref Line(lowerLimit, "Dashed", "Red", "Lower Limit")}
)
)
);
// Save the plot as a JPEG file
bp << savepicture( outputDir || colName || ".jpeg", "JPEG" );
// Close the plot window without saving
);
Close All( data tables, No Save );
And this is the picture with missing data:
And no issue when I drew by the UI directly: