當將 Y 變數作為列表提供給圖形產生器時,如何將箱線圖新增至點?以下範例腳本來自較早的線程(已解決,感謝@jthi )我的允許我將 Y 變數繪製為列表中的點。
我想添加箱線圖另外積分在我的圖表中。 如何在下面的腳本中新增箱型圖?
Names Default To Here(1);
dt = Open("$sample_data\Big Class.jmp");
y_values = {"name", "age", "sex", "weight"};
variables_expr = Expr(Variables(X(:height)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
Insert Into(gb_expr, Name Expr(variables_expr));
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
Show(Name Expr(gb_expr));
Eval(gb_expr);自動化和腳本編寫視窗回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?在 JMP 中互動式建立圖形

將腳本儲存到剪貼簿/腳本窗口
Graph Builder(
Show Control Panel(0),
Variables(X(:height), Y(:name), Y(:age), Y(:sex), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(1)), Box Plot(X, Y, Legend(5))),
Elements(Position(1, 2), Points(X, Y, Legend(2)), Box Plot(X, Y, Legend(6))),
Elements(Position(1, 3), Points(X, Y, Legend(3)), Box Plot(X, Y, Legend(7))),
Elements(Position(1, 4), Points(X, Y, Legend(4)), Box Plot(X, Y, Legend(8))),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{1, [0], 5, [4, -3], 2, [1], 6, [5, -3], 3, [2], 7, [6, -3], 4, [3],
8, [7, -3]}
)}
)
)
)
當原始圖形產生器如下所示時,請查看必須更改哪些內容才能包含 BoxPlots
Graph Builder(
Show Control Panel(0),
Variables(X(:height), Y(:name), Y(:age), Y(:sex), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(1))),
Elements(Position(1, 2), Points(X, Y, Legend(2))),
Elements(Position(1, 3), Points(X, Y, Legend(3))),
Elements(Position(1, 4), Points(X, Y, Legend(4)))
)
返回您的腳本並嘗試進行一些小的修改。 您可以很容易地看到,您缺少 Elements 中的某些內容並且基於您的原始腳本
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
看來你應該嘗試在那裡添加正確格式的箱線圖
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?運行圖表。
打開控制面板
新增您想要的箱線圖。
關閉控制面板
前往紅色三角形並選擇
儲存=>腳本到腳本視窗
檢查程式碼,並更改腳本以添加新腳本具有而舊腳本沒有的附加項目。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?運行您的 JSL,然後將圖表修改為您想要的外觀,然後儲存新圖表中的 JSL。將新的 JSL 添加到此討論軌道,我將查看它。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?@tx尼爾森我一直在這樣做,以互動方式添加箱形圖,然後檢查生成的腳本,在我的原始腳本中進行更改,仍然無法使箱形圖工作。我想我仍然不擅長發現缺少/需要的東西。
會嘗試@jthi現在建議。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?@tx尼爾森以下內容接近我的實際情況。
Names default To Here (1);
Clear Log ();
dt = Open("$sample_data\Semiconductor Capability.jmp");
y_values = {"NPN1", "IVP1", "PNP4", "NPN4"};
variables_expr = Expr(Variables(X(:lot_id)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
Insert Into(gb_expr, Name Expr(variables_expr));
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
Show(Name Expr(gb_expr));
Eval(gb_expr); 這使

但是,我想要以下內容

JMP 產生的腳本是
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) ),
Elements(
Position( 1, 1 ),
Points( X, Y, Legend( 1 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 5 ), Jitter( "None" ) )
),
Elements(
Position( 1, 2 ),
Points( X, Y, Legend( 2 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 6 ), Jitter( "None" ) )
),
Elements(
Position( 1, 3 ),
Points( X, Y, Legend( 3 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 7 ), Jitter( "None" ) )
),
Elements(
Position( 1, 4 ),
Points( X, Y, Legend( 4 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 8 ), Jitter( "None" ) )
),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{1, [0], 5, [4, -3], 2, [1], 6, [5, -3], 3, [2], 7, [6, -3], 4, [3],
8, [7, -3]}
)}
)
)
);問題是如何修改這篇文章中的頂部腳本以除了點之外還包括箱形圖?
在 Points () 下面加上 Box Plots () 並沒有給我兩者。
我想我對箱線圖 () 的放置不正確。 這裡需要幫助。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?我認為您使用了預設的“箱線圖”離群值。
您是否正在尋找連接所有點的「箱線圖」分位數方法?

Graph Builder(
Size( 1135, 705 ),
Show Control Panel( 0 ),
Variables(
X( :“S-b"n ),
Y( :C),
Color( :“S-b"n )
),
Elements( Box Plot( X, Y, Legend( 4 ), Box Type( "Quantile" ) ) )
);
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?需要非常小的更改才能產生您想要的圖表。
運行圖形產生器的初始腳本產生的 JSL 是
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 2 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 3 ) ) ),
Elements( Position( 1, 4 ), Points( X, Y, Legend( 4 ) ) )
);
當人們查看創建上述圖形產生器程式碼的 JSL 時,會發現只有 2 個部分完成了真正的工作。
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
為圖形產生器建立外殼
Graph Builder(
Show Control Panel( 0 ),
);
JSL
variables_expr = Expr(Variables(X(:lot_id)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
產生程式碼
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) )
然後,
Insert Into(gb_expr, Name Expr(variables_expr));
將變數 ( X(.................) JSL 插入 Graph Builder() 程式碼中
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) )
);
現在需要做的是構建
Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 2 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 3 ) ) ),
Elements( Position( 1, 4 ), Points( X, Y, Legend( 4 ) ) )
創建這些程式碼行的 JSL 是
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
它會循環遍歷每個 Y 值並一次建立一行元素,並將其插入到 Graph Builder() JSL 中。
最後,
Eval(gb_expr);
運行已完成的 Graph Builder JSL
那麼現在,需要改變什麼。
基本上,如果查看原始腳本創建的 JSL 與經過新修改的圖形生成器保存的 JSL 之間的差異,在原始腳本輸出中,Elements 結構為
Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) )
其中「已儲存程式碼」的「元素」部分包含「點」和「箱線圖」部分
Elements(
Position( 1, 1 ),
Points( X, Y, Legend( 1 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 5 ), Jitter( "None" ) )
)
因此,需要更改的只是將第二部分添加到生成 Elements 部分的程式碼中。
For Each( {y_col, idx}, y_values,
Eval(
Eval Expr(
Insert Into(
gb_expr,
Name Expr(
Elements(
Position( 1, Expr( idx ) ),
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ) ),
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
)
)
)
)
)
);
如果將所有這些放在一起,新腳本就是
Names Default To Here( 1 );
Clear Log();
dt = Open( "$sample_data\Semiconductor Capability.jmp" );
y_values = {"NPN1", "IVP1", "PNP4", "NPN4"};
variables_expr = Expr(
Variables( X( :lot_id ) )
);
For Each( {y_col}, y_values,
temp_expr = Expr( Y() );
Insert Into( temp_expr, Name Expr( As Column( dt, y_col ) ) );
Insert Into( variables_expr, Name Expr( temp_expr ) );
);
gb_expr = Expr(
Graph Builder( Show Control Panel( 0 ) )
);
Insert Into( gb_expr, Name Expr( variables_expr ) );
For Each( {y_col, idx}, y_values,
Eval(
Eval Expr(
Insert Into(
gb_expr,
Name Expr(
Elements(
Position( 1, Expr( idx ) ),
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ) ),
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
)
)
)
)
)
);
Show( Name Expr( gb_expr ) );
Eval( gb_expr );回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?@tx尼爾森謝謝。
我不會輕易想到這個。
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
如何將點中的預設標記變更為“+”或“方塊”。 這並不能解決問題
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ), marker ("square") )改變標記互動式地表示我需要透過 sendToReport () 為每個 Y 變數指示標記變更。 如何同時對所有 Y 變數執行此操作?
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?取決於你在哪裡做,在哪裡看到什麼會有所不同。 如果您從 Legend 執行此操作,請參閱以下範例:
從傳說中改變它,你會得到類似的東西
{Legend Model(4, Properties(0, {Marker("Circle")}, Item ID("NPN4", 1)))}
因此從腳本索引中搜尋圖例模型

從那裡獲取腳本,修改它以滿足您的需求,但保持盡可能簡單(添加第二個 Y 軸)並測試它
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:sex), Y(:height), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(3))),
Elements(Position(1, 2), Points(X, Y, Legend(1)))
);
server = gb << Get Legend Server;
item = server << Get Legend Item(1, 1);
item << Set Properties({Marker("Circle")});
您成功地更改了一張圖上的標記。 然後你會問:我如何在所有地塊上更改它們? 然後更詳細地探索腳本,似乎提供了一些索引
item = server << Get Legend Item(1, 1);
檢查<< 從腳本索引中獲取圖例項目並希望它在那裡,如果它不存在,則探索其他圖例相關對象並希望它們以類似的方式工作(或者只是嘗試將訊息發送到伺服器<< get legend Ctrl+ Space這裡)。
server << Get Legend Items;
{{LegendModelItem(Label("height"), Type("Marker"))},
{LegendModelItem(Label("weight"), Type("Marker"))}}
現在您有一個圖例項目清單。 嘗試循環該列表,看看會發生什麼
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:sex), Y(:height), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(3))),
Elements(Position(1, 2), Points(X, Y, Legend(1)))
);
server = gb << Get Legend Server;
For Each({item}, server << Get Legend Items,
item << Set Properties({Marker("Circle")});
);
更簡單的選擇是將標記設為資料表的行狀態(如果這適合您)。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?@jthi謝謝。 有沒有辦法在先繪製點時更改標記,而不是稍後獲取圖例伺服器的句柄,然後更改每個 Y 變數的標記?
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?難道有什麼原因導致之後無法更改嗎?
您可以使用 SendToReport 並在 Dispatch 部分中建立 Legend 模型,其想法與腳本中其他部分的建置類似。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?@jthi當然事情之後可能會改變。 在繪製點時更改標記對我來說似乎是一條更簡單的路線。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?@jthi @tx尼爾森在下面的主腳本中,我在 Eval() 下添加了本地資料過濾器 () ,它按預期工作
Eval( gb_expr <<LOCAL data="https://community.jmp.com/" filter=""></LOCAL>
但如果我添加用於更新標記的腳本,圖表就會繪製兩次!
Eval(
server = gb_expr << Get Legend Server;
For Each( {item}, server << Get Legend Items, item << Set Properties( {Marker( "Circle" )} ) );
);<BR />
Names Default To Here( 1 );
Clear Log();
dt = Open( "$sample_data\Semiconductor Capability.jmp" );
y_values = {"NPN1", "IVP1", "PNP4", "NPN4"};
variables_expr = Expr(
Variables( X( :lot_id ) )
);
For Each( {y_col}, y_values,
temp_expr = Expr( Y() );
Insert Into( temp_expr, Name Expr( As Column( dt, y_col ) ) );
Insert Into( variables_expr, Name Expr( temp_expr ) );
);
gb_expr = Expr(
Graph Builder( Show Control Panel( 0 ) )
);
Insert Into( gb_expr, Name Expr( variables_expr ) );
For Each( {y_col, idx}, y_values,
Eval(
Eval Expr(
Insert Into(
gb_expr,
Name Expr(
Elements(
Position( 1, Expr( idx ) ),
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ) ),
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
)
)
)
)
)
);
//Show( Name Expr( gb_expr ) );
Eval( gb_expr <<LOCAL data="https://community.jmp.com/" filter=""></LOCAL>第二個圖表包含更新的標記。
如何使用更新的標記和本機資料篩選器繪製單一圖表?
我想,我無法在我請求幫助的地方正確放置最後一塊用於標記更改的位置。
回覆:當將 Y 變數作為清單提供給圖形產生器時,如何將箱型圖新增至點?您不想運行 gb_expr 兩次。 您想要獲取從 gb_expr 獲得的引用並將這些訊息發送給它
gb = Eval( gb_expr );
gb << Local data Filter(...)
server = gb << get legend server;