如何使用 JSL 動態新增圖形元素語句大家好,我對 JMP 和 JSL 還不太熟悉,但對程式設計比較熟悉。我正在嘗試建立一個 JSL 腳本,該腳本會取得一個參數名稱清單(我在「PlotVars」陣列中定義),然後將它們繪製在同一張圖表上的不同位置。我希望無論這個數組中定義了多少個參數,這個腳本都能正常工作(以防每次使用時我需要添加或減少參數)。我可以使用下面的程式碼來實現這個功能,但所有繪圖都預設使用點,我希望它們使用線。我的理解是為每個位置使用多個元素語句。我認為問題出在第二行,也就是我初始化“var_line”變數的地方。如果我將其初始化為 Expr(),它會產生元素語句,但無法正確運行它們。如果我將它們初始化為 Parse(),情況也一樣。歡迎大家提出任何解決這個問題的建議。我使用的是 JMP 18。
編輯(jthi):新增了 jsl 格式
var_expr = Expr(
Variables(X(As Column("Start Alignment of " || DataSet_1)))
);
var_line = Expr();//Unable to dymanically add elements to the graph. still unsure why
For(i = 1, i <= N Items(PlotVars), i++,
Insert Into(var_expr, Eval Expr(Y(As Column(PlotVars[Expr(i)] || " of " || DataSet_1), )));
Insert Into(
var_expr,
Eval Expr(Y(As Column(PlotVars[Expr(i)] || " of " || DataSet_2), Position(Expr(i)), ))
);
Insert Into(
var_line,
Eval Expr(Elements(Position(1, Expr(i)), Line(X, Y(1), Y(2)), Legend(4)))
);
);
plot = Substitute(
Expr(
Data Table("Comparison of" || DataSet_1 || "with" || DataSet_2) <<
Graph Builder(Size(809, 629), Show Control Panel(0), vvv, yyy)
),
Expr(vvv), Name Expr(var_expr),
Expr(yyy), Name Expr(test)
);
Eval(plot);
<
var_expr = Expr(變數(X(作為列("開始對齊" || DataSet_1) )));
var_line = Expr();//無法動態地在圖形中加入元素。仍然不確定為什麼
對於(i=1,i<=N 個項目(PlotVars),i++,
插入(var_expr,Eval Expr(Y(以列(PlotVars[expr(i)] || " of " || DataSet_1),)));
插入(var_expr,Eval Expr(Y(以列(PlotVars[expr(i)] || " of " || DataSet_2),位置(expr(i)),)));
插入(var_line,Eval Expr(元素(位置(1,expr(i)),線(X,Y(1),Y(2)),圖例(4))));
);
圖 = 替代(
表達式(
資料表(“比較”|| DataSet_1 ||“與”|| DataSet_2)<<
圖形產生器(
尺寸(809,629),
顯示控制面板(0),
觀光局,
年
)),
Expr(vvv), 名稱 Expr(var_expr),
Expr(yyy),名稱 Expr(測試)
);
評估(情節);
>
自動化和腳本回覆:如何使用 JSL 為圖形動態新增元素語句您希望圖表看起來是什麼樣的? JMP 創建的腳本是什麼樣的?它與您使用 JSL 創建的腳本相比如何?
Data Table("Comparison of" || DataSet_1 || "with" || DataSet_2) <<
Graph Builder(
Size(809, 629),
Show Control Panel(0),
Variables(
X(As Column("Start Alignment of " || DataSet_1)),
Y(As Column(PlotVars[1] || " of " || DataSet_1)),
Y(As Column(PlotVars[1] || " of " || DataSet_2), Position(1)),
Y(As Column(PlotVars[2] || " of " || DataSet_1)),
Y(As Column(PlotVars[2] || " of " || DataSet_2), Position(2))
),
test
)
關於動態建構圖形產生器,還有許多相關資料。以下是一些Scripters Club 的錄音:圖形產生器中的 JSL以及回覆所有人:如何為圖形產生器編寫動態內容腳本
回覆:如何使用 JSL 為圖形動態新增元素語句這個腳本創建的圖形與我期望的完全一致,只不過它在元素語句中使用了點/平滑器來創建圖形(請注意,為了縮短腳本長度,我們刪除了一些變數)。以下是腳本輸出的圖形程式碼:
Graph Builder(
Size( 809, 629 ),
Show Control Panel( 0 ),
Variables(
...
)
),
Elements(
Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Legend( 1 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 2 ) )
),
Elements(
Position( 1, 2 ),
Points( X, Y( 1 ), Y( 2 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 4 ) )
),
Elements(
Position( 1, 3 ),
Points( X, Y( 1 ), Y( 2 ), Legend( 5 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 6 ) )
),
Elements(
Position( 1, 4 ),
Points( X, Y( 1 ), Y( 2 ), Legend( 7 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 8 ) )
),
Elements(
Position( 1, 5 ),
Points( X, Y( 1 ), Y( 2 ), Legend( 9 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 10 ) )
)
);
我比較希望用 Lines 來代替:
Graph Builder(
Size( 696, 590 ),
Show Control Panel( 0 ),
Variables(
...
)
),
Elements( Position( 1, 1 ), Line( X, Y( 1 ), Y( 2 ), Legend( 11 ) ) ),
Elements( Position( 1, 2 ), Line( X, Y( 1 ), Y( 2 ), Legend( 12 ) ) ),
Elements( Position( 1, 3 ), Line( X, Y( 1 ), Y( 2 ), Legend( 13 ) ) ),
Elements( Position( 1, 4 ), Line( X, Y( 1 ), Y( 2 ), Legend( 14 ) ) ),
Elements( Position( 1, 5 ), Line( X, Y( 1 ), Y( 2 ), Legend( 15 ) ) )
);
每當嘗試「插入」元素語句時,它只會加入一個巢狀的元素語句,而不是單獨的元素語句。而且圖形產生器似乎會忽略這些巢狀的元素語句。
回覆:如何使用 JSL 為圖形動態新增元素語句
看更多...
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
plotvars = {"NPN1", "NPN2", "NPN3", "NPN4", "PNP1"};
xcol = "wafer";
gb_expr = Expr(Graph Builder(Size(809, 629), Show Control Panel(0)));
var_expr = EvalExpr(Variables(X(Expr(NameExpr(As Column(dt, xcol))))));
For Each({colname, idx}, plotvars,
Insert Into(var_expr, Eval Expr(Y(Expr(NameExpr(As Column(dt, colname))))));
);
Insert Into(gb_expr, Name Expr(var_expr));
For(idx = 1, idx <= N Items(plotvars), idx++,
elem_expr = Substitute(
Expr(Elements(Position(1, _pos_), Line(X, Y, Legend(_lgnd_)))),
Expr(_pos_), idx,
Expr(_lgnd_), idx
);
Insert Into(gb_expr, Name Expr(elem_expr));
);
// Show(gb_expr);
gb = Eval(EvalExpr((Send(dt, Expr(gb_expr)))));
gb_expr = Graph Builder(
Size(809, 629),
Show Control Panel(0),
Variables(X(:wafer), Y(:NPN1), Y(:NPN2), Y(:NPN3), Y(:NPN4), Y(:PNP1)),
Elements(Position(1, 1), Line(X, Y, Legend(1))),
Elements(Position(1, 2), Line(X, Y, Legend(2))),
Elements(Position(1, 3), Line(X, Y, Legend(3))),
Elements(Position(1, 4), Line(X, Y, Legend(4))),
Elements(Position(1, 5), Line(X, Y, Legend(5)))
);
回覆:如何使用 JSL 為圖形動態新增元素語句太棒了,這個想法奏效了。我只需要在圖形生成器級別插入“元素”命令,而不是嘗試將元素命令單獨構建成一個表達式。