The script below loads some data and should create twice the same plot.<BR />The first one by referring to the column name by using a variable (test1), the second one by calling the column name directly.
The second one works fine, but for the first one I get an empty plot area. I guess there is a problem with how I define or call test1. I have tried different approaches, but so far nothing worked.
Names Default To Here( 1 );
// Import the Excel file with specified settings
dt = Open(
"/Y:/.../file.xlsx",
Worksheets( "Pivot table for JMP" ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Headers Start on Row( 2 ),
Data Starts on Row( 3 )
)
);
// Filter rows to include only "AAA" in "Common Designation"
dt_AAA = dt << Subset(
Rows( :Common Designation == "AAA" ),
Include All Columns,
Name( "Filtered AAA" )
);
size = "AAA" ;
Match( size,
"AAA", test1 = column ("PL (min)"),
);
New Window( size,
V List Box(
Graph Builder(
Size( 500, 297 ),
Show Control Panel( 0 ),
Variables( X( :test1 ), Y( :Chemistry ), Color( :Chemistry ) ),
Elements( Points( X, Y, Legend( 106 ) ) )
),
Graph Builder(
Size( 500, 297 ),
Show Control Panel( 0 ),
Variables( X( :"PL (min)"n ), Y( :Chemistry ), Color( :Chemistry ) ),
Elements( Points( X, Y, Legend( 106 ) ) )
),
),
);
如果我理解正確,您只需要刪除第一個 Graph Builder 腳本中 test1 前面的冒號。以下是一個可運行的範例腳本:
Names Default To Here (1);
dt = open ("$SAMPLE_DATA/big class.jmp");
test1 = column ("weight");
Graph Builder (
Variables (X(test1), Y(:height), color (:sex))
);
一個查找這類漏洞的好方法:
從有問題的腳本中不斷刪除程式碼行,直到只剩下足以重現錯誤的程式碼行為止。
重要提示:程式碼應包含產生錯誤所需的所有要素—對所有執行程式碼的人都適用*)
這樣做有兩個優點:
大多數情況下,錯誤都能自動找到。刪除一行程式碼,錯誤就消失了。
- 剩餘的程式碼非常短,這使得查找錯誤變得容易得多。
*)在我的系統上,它崩潰並出現以下錯誤訊息:

更好的辦法是:使用範例文件之一,例如@Jed_Campbell的範例。
這樣做還有另一個好處:你可以區分:
我的資料表中存在錯誤(而範例資料中沒有此錯誤)。
我的腳本有錯誤(因為我可以用範例資料重現該錯誤)。