私は JMP を初めて使用しており、複数のボックス プロットをエクスポートする際に問題が発生しています。私の目標は、X 軸変数を別のパラメーターでグループ化したプロットを作成することです。ただし、特定の列を 1 つ使用するとプロットは正しいものの、エクスポートされた出力には一部の X 軸データが欠落しています。
これが私のコードです:
//桌面創建資料夾帶上當天日期
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 );そして、これはデータが欠落している画像です:

UI で直接描画した場合も問題はありませんでした。

データの例 (.jmp ファイル) を提供できますか?
返信ありがとうございます。添付ファイルに jmp を添付します。
私の最初の推測は、グラフビルダーがスクリプト内で正しく構築されていないということです(手動でグラフを作成して取得したスクリプトとスクリプトを比較してください)。ボックスプロットの要素の部分が間違っている可能性が高いです。
bp = dt << Graph Builder(
Show Control Panel(0),
Show Legend(0),
Variables(
X(:Vendor1),
Y(Eval(col)), // Box plot for the current column
Group X(:Vendor2)
),
Elements(Box Plot(X, Y, Legend(1))),
// 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")}
)
)
);
また、仕様限界行を削除するような方法でデータを変更することも検討します。これは、実際にはデータの扱い方としては望ましくないためです。仕様限界行を変数に格納したり、列プロパティとして設定したり、テーブル変数に格納したりすることができます。
要素の仕様では、X変数とY変数を選択する必要があります。コードではそれがチェックされていません。

要素の仕様を次のように変更します
Elements( Box Plot( X, Y, Legend( 1 ) ) )
はい、それが問題です...笑! 助言をありがとう、次回は詳細をすべて調べます...
参照図面に限界値が含まれていないことを確認しました。まだ理由を理解しようとしており、さらに結果を調べます。現在、私が知っている唯一の方法は、限界値を新しいデータ テーブルで分離し、追加のループ コードで限界データ テーブルを参照することですが、これは私にとって複雑です。