使用 JSL 在圖形產生器中隱藏圖例項我在使用 JSL 中的圖形產生器時遇到了一個惱人的問題。為了在散佈圖上顯示點和更平滑,我正在更改點的透明度。我可以讓這項工作足夠好,但是當我稍後在 JSL 中操作繪圖時,預設情況下,點將被添加回圖例,而不是保持隱藏,我認為是因為 JMP 認為它們不再是多餘的。我知道您可以在圖形產生器中手動取消選取不想顯示的項目,但是有沒有辦法在 JSL 中執行此操作?


回覆:使用 JSL 在圖形產生器中隱藏圖例項謝謝你@anne_sa 。你的訊息為我指明了正確的方向。
回覆:使用 JSL 在圖形產生器中隱藏圖例項謝謝@tx尼爾森和@jjswan33為您解答!
我需要稍微調整它以使其與我的腳本相匹配,但我想我會工作的。
再次感謝 :)
回覆:使用 JSL 在圖形產生器中隱藏圖例項我找到了一個替代解決方案,在我看來,它比吉姆的蠻力方法更乾淨。
相反,我在函數的開頭定義了兩個列表:
p = {};
l = {};
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
For(i=0, i < NSplits, i+=1,
p = Insert(p, -1);
l = Insert(l, i);
);
pl = Insert(p, l);建立點和線(在我的例子中)圖例項目所需的兩個列表,然後將這些列表作為矩陣傳遞到圖形產生器調度中,如下所示:
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, Matrix(p), 9, Matrix(l)} ),
Position( Matrix(pl))}
)完整版更新功能:
RadPlotCreator1XGroupTest = Function({dt, XCol, YCol, OverlayCol, GroupXCol}, {Default Local},
p = {};
l = {};
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
For(i=0, i < NSplits, i+=1,
p = Insert(p, -1);
l = Insert(l, i);
);
pl = Insert(p, l);
gb = dt << Graph Builder(
Size( 849, 622 ),
Fit to Window( "Off" ),
Show Control Panel(0),
Grid Color( "Black" ),
Variables(
X( XCol ),
Y( YCol ),
Group X( GroupXCol ),
Overlay( OverlayCol )
),
Elements(Points(X, Y, Legend(3)), Smoother( X, Y, Legend( 9 ) )),
SendToReport(
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, Matrix(p), 9, Matrix(l)} ),
Position( Matrix(pl))}
)
)
);
sb = report(gb)[ScaleBox(5)];
For(i=0, i < NSplits, i+=1,
sb << Legend Model(3, Properties(i, {Transparency(0.2)}));
);
frame_list = gb << xpath("//FrameBox");
num_frames = N Items (frame_list);
For(i=1, i <= num_frames, i+=1,
Report(gb)[Framebox(i)] << Background Color(White);
Report(gb)[Framebox(i)] << Grid Line Order( Back );
Report(gb)[Framebox(i)] << Reference Line Order( Back );
Report(gb)[Framebox(i)] << Frame Size(250, 250);
Report(gb)[Framebox(i)] << X Axis(0, 150, Inc(20), Minor Ticks(1),
Add Ref Line( 70, Solid, "Black", "", 2 ),
Add Ref Line( 120, Solid, "Black", "", 2 ),
Add Ref Line( 135, Solid, "Black", "", 2 ), Show Major Grid( 1 ));
Report(gb)[Framebox(i)] << Y Axis(Minor Ticks(1));
);
gbp = Report( gb );
img = gbp << getpicture();
return(img);
);
回覆:使用 JSL 在圖形產生器中隱藏圖例項這是我用來解決這類問題的強力方法。我只需建立所需的 JSL 程式碼,然後運行我創建的 JSL。 請注意,在我使用的 Big Class 資料表中,我新增了一個額外的年齡組,即 18 歲。
Names Default To Here( 1 );
dt = Current Data Table();
// Find the number of Age groups
Summarize( dt, ageGroups = by( :age ) );
// Build the JSL
theExpr =
"Graph Builder(
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Points( X, Y, Legend( 6 ) ), Box Plot( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch(
{},
\!"400\!",
LegendBox,
{Legend Position(
{6, [ -1";
For( i = 2, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", -1"
);
theExpr = theExpr || "], 7, [0";
For( i = 1, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", " || Char( i )
);
theExpr = theExpr || ", -3]}
), Position( {-1";
For( i = 2, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", -1"
);
For( i = 0, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", " || Char( i )
);
theExpr = theExpr || ", -3]} ) } )));";
// Execute the JSL string
eval(parse(theExpr));

回覆:使用 JSL 在圖形產生器中隱藏圖例項糟糕,複製/貼上錯誤,抱歉造成混亂!
讓我們重做一次(使用 JMP15)!
首先我有以下圖表:

對應的腳本是:
Graph Builder(
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Points( X, Y, Legend( 6 ) ), Box Plot( X, Y, Legend( 7 ) ) )
)
我手動修改圖例並取消選擇與點關聯的項目:

我得到這個圖:

更新後的腳本是:
Graph Builder(
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Points( X, Y, Legend( 6 ) ), Box Plot( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{6, [-1, -1, -1, -1, -1, -1], 7, [0, 1, 2, 3, 4, 5, 6, -3]}
), Position( {-1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, -3} )}
)
)
)有沒有簡單的方法可以使用 JSL 來管理第二步?
回覆:使用 JSL 在圖形產生器中隱藏圖例項我個人在 JMP 12 和 JMP 14 中都獲得了雙重圖例。我之前沒有發布我的程式碼,但下面是我用來繪製出現問題的圖的函數。就我而言,我相信發生的情況是,一旦我使用代碼位設定點的透明度,JMP 就不再認為點圖例項是多餘的並顯示結果。
RadPlotCreator1X1YGroup = Function({dt, XCol, YCol, OverlayCol, GroupXCol, GroupYCol}, {Default Local},
gb = dt << Graph Builder(
Size( 849, 622 ),
Fit to Window( "Off" ),
Show Control Panel(0),
Grid Color( "Black" ),
Variables(
X( XCol ),
Y( YCol ),
Group X( GroupXCol ),
Group Y( GroupYCol ),
Overlay( OverlayCol )
),
Elements(Points(X, Y, Legend(3)), Smoother( X, Y, Legend( 9 ) )),
SendToReport(
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"",
ScaleBox,
{}
)
)
);
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
sb = report(gb)[ScaleBox(5)];
For(i=0, i < NSplits, i+=1,
sb << Legend Model(3, Properties(i, {Transparency(0.2)}));
);
frame_list = gb << xpath("//FrameBox");
num_frames = N Items (frame_list);
For(i=1, i <= num_frames, i+=1,
Report(gb)[Framebox(i)] << Background Color(White);
Report(gb)[Framebox(i)] << Grid Line Order( Back );
Report(gb)[Framebox(i)] << Reference Line Order( Back );
Report(gb)[Framebox(i)] << Frame Size(250, 250);
Report(gb)[Framebox(i)] << X Axis(0, 150, Inc(20), Minor Ticks(1),
Add Ref Line( 70, Solid, "Black", "", 2 ),
Add Ref Line( 120, Solid, "Black", "", 2 ),
Add Ref Line( 135, Solid, "Black", "", 2 ), Show Major Grid( 1 ));
Report(gb)[Framebox(i)] << Y Axis(Minor Ticks(1));
);
gbp = Report( gb );
img = gbp << getpicture();
return(img);
);回覆:使用 JSL 在圖形產生器中隱藏圖例項您使用的是哪個版本的 JMP,以及在哪個作業系統上。使用您提供的 JSL,我無法獲得您指定的結果。對於 JMP 15 我得到

在 JMP 13 和 JMP 14 中我得到:

在 JMP 11 和 JMP 12 中,我得到:

但我無法獲得您使用不同標記以及圖例中的點和矩形標記呈現的圖表。
回覆:使用 JSL 在圖形產生器中隱藏圖例項你好@tx尼爾森,
感謝您的回覆。
然而,我不想完全隱藏或刪除圖例,而只是其中的一部分。
預設情況下,我有以下圖表:

我想只隱藏圖例中的點項目以獲得該項目:

顯然,圖例位置選項中的“-1”意味著“隱藏此項目”,但我不知道如何在沒有有關圖表的事先資訊的情況下輕鬆使用此選項。
我希望它更清楚。
回覆:使用 JSL 在圖形產生器中隱藏圖例項您可以使用「顯示圖例」元素來控製圖例的顯示或隱藏。這是腳本索引中顯示它的條目
幫助==>腳本索引

您也可以使用 JMP 中的顯示樹功能刪除整個圖例元件
gb = Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Box Plot( X, Y))
);
report(gb)[LegendBox(1)]<<DELETE></DELETE>
回覆:使用 JSL 在圖形產生器中隱藏圖例項大家好,
我目前面臨同樣的問題:使用 JSL 隱藏圖形產生器圖例的一部分。
我認為“圖例”或“圖例位置”選項可能會有所幫助,但我很難完全理解它是如何工作的,特別是如果我們不知道組的數量。
例如,我想使用 Big Class 表來建立這種圖表,我不想在圖例中顯示點項:

對應的腳本是:
Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Box Plot( X, Y, Legend( 4 ) ), Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{4, [0, 1, 2, 3, 4, 5, 6, -3], 5, [-1, -1, -1, -1, -1, -1]}
), Position( {0, 1, 2, 3, 4, 5, 6, -3, -1, -1, -1, -1, -1, -1} )}
)
)
)有沒有辦法在不知道年齡變數的層級數的情況下概括該過程?
任何意見將不勝感激:)謝謝
回覆:使用 JSL 在圖形產生器中隱藏圖例項我想 JSL 沒有解決這個問題的方法。如果真是這樣的話,那就應該如此了。