WINDOWS 10 > JMP 17.2 > 圖形產生器 > 散佈圖 > 動態聚類註釋JMP 社群您好,
Windows 專業版 10 - JMP 17.2
我有一些資料投影在 2D UMAP 上,我想在圖形產生器中的 UMAP2 x UMAP1 散佈圖之上自動插入格式化(顏色和大小)簇 ID。我設法透過單獨繪製簇 ID 並將它們合併到主 FrameBox 來獲取簇 ID。儘管如此,這還是不能令人滿意,因為我無法控制這些 Cluster ID 標籤的大小和顏色。
我在 Add Graphics Script() 命令中嘗試了循環,但無法使其工作。

這是我用來產生上面的情節的腳本
Names Default to Here(1);
dt = Data Table ("ANNOTATION of 2D CLUSTERS");
dt_sum = dt << Summary(
Group( :WARD UMAP CLUSTERS ),
Mean( :UMAP1 CENTER by CLUSTER ),
Mean( :UMAP2 CENTER by CLUSTER ),
Freq( "None" ),
Weight( "None" ),
statistics column name format( "column" )
);
gb = dt << Graph Builder(
Size( 483, 675 ),
Fit to Window( "Off" ),
Page Level Fill Color( "White" ),
Graph Spacing( 15 ),
Spacing Borders( 1 ),
Variables( X( :UMAP1 ), Y( :UMAP2 ), Color( :WARD UMAP CLUSTERS ) ),
Elements( Points( X, Y, Legend( 27 ) ) )
);
gbr = report (gb);
main_x_max = gbr [AxisBox(1)] << Get Max;
main_x_min = gbr [AxisBox(1)] << Get Min;
main_y_max = gbr [AxisBox(2)] << Get Max;
main_y_min = gbr [AxisBox(2)] << Get Min;
F_size = gbr[FrameBox(1)] << Get Size;
xbe = Expr(dt_sum << Graph Builder(
Size( _W_, _H_ ),
Fit to Window( "Off" ),
Page Level Fill Color( "White" ),
Graph Spacing( 15 ),
Spacing Borders( 1 ),
Variables(
X( :UMAP1 CENTER by CLUSTER ),
Y( :UMAP2 CENTER by CLUSTER ),
Color( :WARD UMAP CLUSTERS )
),
Elements(
Bar( X, Y, Legend( 4 ), Bar Style( "Float" ), Label( "Label by Row" ) )
)
)
);
xbx = Substitute(Name Expr (xbe), Expr (_W_), F_Size [1],
Expr (_H_), F_size [2]
);
xb = Eval (xbx);
xbr = report (xb);
xbr [AxisBox (1)] << max (main_x_max);
xbr [AxisBox (1)] << min (main_x_min);
xbr [AxisBox (2)] << max (main_y_max);
xbr [AxisBox (2)] << min (main_y_min);
xbr [FrameBox(1)] << Copy Frame Contents;
gbr [FrameBox(1)] << Paste Frame Contents;
謝謝。
最好的,
TS
自動化和腳本編寫數據探索和視覺化視窗回覆:WINDOWS 10 > JMP 17.2 > 圖形產生器 > 散佈圖 > 動態聚類註釋您可以新增「額外」x 和 y 軸,然後使用它們。請注意,平均值 (UMAP2) 的顏色已更改,因為它不能保留為預設值,否則它們將使用值顏色。您也可以將標記大小更改為 0,如果您不想突出顯示“平均”點或更改標記

Graph Builder(
Size(438, 629),
Show Control Panel(0),
Fit to Window("Off"),
Page Level Fill Color("White"),
Graph Spacing(15),
Spacing Borders(1),
Variables(
X(:UMAP1),
X(:UMAP1 CENTER by CLUSTER, Position(1)),
Y(:UMAP2),
Y(:UMAP2 CENTER by CLUSTER, Position(1)),
Color(:WARD UMAP CLUSTERS)
),
Elements(
Points(X(1), Y(1), Legend(27)),
Points(
X(2),
Y(1),
Color(0),
Legend(32),
Summary Statistic("Mean"),
Label("Label by Row")
)
),
SendToReport(
Dispatch({}, "400", ScaleBox,
{Legend Model(
32,
Properties(0, {Line Color(16)}, Item ID("Mean(UMAP2)", 1))
)}
)
)
);
</CODE></P>
<P> </P></LINGO-BODY><LINGO-SUB id="lingo-sub-825409" slang="en-US" mode="CREATE">回覆:WINDOWS 10 > JMP 17.2 > 圖形產生器 > 散佈圖 > 動態聚類註釋</LINGO-SUB><LINGO-BODY id="lingo-body-825409" slang="en-US" mode="CREATE"><P>嗨,賈莫,</P>
<P>感謝您為我最初的挑戰提供了一個更簡單的解決方案。不過,我想更改標籤的字體大小和顏色以使繪圖更具可讀性。您對我如何完成這項任務有任何線索嗎?</P>
<P> </P>
<P>此致,</P>
<P>TS</P>
<P> </P></LINGO-BODY><LINGO-SUB id="lingo-sub-825424" slang="en-US" mode="CREATE">回覆:WINDOWS 10 > JMP 17.2 > 圖形產生器 > 散佈圖 > 動態聚類註釋</LINGO-SUB><LINGO-BODY id="lingo-body-825424" slang="en-US" mode="CREATE"><P>我認為那麼您將不得不使用圖形腳本,因為標籤沒有那麼多自訂選項(要更改文字大小,您必須更改字體首選項)。</P></LINGO-BODY><LINGO-SUB id="lingo-sub-825436" slang="en-US" mode="CREATE">回覆:WINDOWS 10 > JMP 17.2 > 圖形產生器 > 散佈圖 > 動態聚類註釋</LINGO-SUB><LINGO-BODY id="lingo-body-825436" slang="en-US" mode="CREATE"><P>有趣的是,長條圖的標籤有一個調整字體的命令,但點圖沒有?<BR /> <A href="https://community.jmp.com/t5/JMP-Wish-List/Graph-builder-bar-chart-data-label-control/m-p/343142#U343142" class="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa" target="_blank">圖形產生器條形圖資料標籤控制項</A>-> 對於其他繪圖類型也很有趣?<BR /><BR /></P><P> </P><PRE><CODE class=" language-jsl">Graph Builder(
Variables( X( :WARD UMAP CLUSTERS ) ),
Elements( Bar( X, Legend( 5 ), Label( "Label by Value" ) ) )
);
labels = (current report()[FrameBox(1)] << find segs)[1];
labels << Set Font( "", 18, "", 0 )
回覆:WINDOWS 10 > JMP 17.2 > 圖形產生器 > 散佈圖 > 動態聚類註釋大家好,
我再一次試著讓它變得比必要的更複雜。
這是我創建的簡短 JSL 腳本,它可以完成我需要的一切。
Names Default to Here(1);
dt = Data Table ("ANNOTATION of 2D CLUSTERS");
Summarize (dt, clu_id = By (:WARD UMAP CLUSTERS), x_pos = Mean (:UMAP1 CENTER by CLUSTER), y_pos = Mean(:UMAP2 CENTER by CLUSTER));
clu_n = N items (clu_id);
colors = {};
vect = dt:WARD UMAP CLUSTERS << Get Property ("Value Colors");
For (j = 1, j <= clu_n, j++,
insert into(colors, num (word(-1, char(vect [j]), "=")))
);
gb = dt << Graph Builder(
Size( 483, 675 ),
Fit to Window( "Off" ),
Page Level Fill Color( "White" ),
Graph Spacing( 15 ),
Spacing Borders( 1 ),
Variables( X( :UMAP1 ), Y( :UMAP2 ), Color( :WARD UMAP CLUSTERS ) ),
Elements( Points( X, Y, Legend( 27 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
10,
Description( "" ),
Text Size (14);
For( i = 1, i <= clu_n, i++,
Label = clu_id [i];
Fill Color ("white");
Transparency (0.85);
Circle ({x_pos [i], y_pos [i]+0.25}, 0.5, "FILL");
Transparency (1);
Text Color (colors [i]);
Text( center justified, {x_pos [i], y_pos [i]}, Label );
)
)}
)
)
);
儘管我不確定我收集值顏色的粗略方法是否有效,但它確實有效。
最好的,
TS
回覆:WINDOWS 10 > JMP 17.2 > 圖形產生器 > 散佈圖 > 動態聚類註釋我覺得你的方法很好。您也可以使用 Arg() 從「things」的值顏色清單中取得項目。我也會在圖形腳本內部評估圖形腳本外部的變量,以避免變數遺失時出現各種煩人的問題。
我最有可能使用關聯數組來收集 id、顏色、x 和 y 座標。與此相關的一個問題可能是 Summarize 和 Associative Array 可能具有不同的排序,必須考慮到這一點(我在這裡沒有這樣做)。
Names Default To Here(1);
dt = Data Table("ANNOTATION of 2D CLUSTERS");
Summarize(
dt,
clu_id = By(:WARD UMAP CLUSTERS),
x_pos = Mean(:UMAP1 CENTER by CLUSTER),
y_pos = Mean(:UMAP2 CENTER by CLUSTER)
);
vect = dt:WARD UMAP CLUSTERS << Get Property("Value Colors");
aa_colors = Associative Array();
For Each({item, idx}, vect,
aa_colors[Arg(item, 1)] = Associative Array();
aa_colors[Arg(item, 1)]["Color"] = Arg(item, 2);
aa_colors[Arg(item, 1)]["X"] = x_pos[idx];
aa_colors[Arg(item, 1)]["Y"] = y_pos[idx];
);
gb = dt << Graph Builder(
Size(483, 675),
Fit to Window("Off"),
Page Level Fill Color("White"),
Graph Spacing(15),
Spacing Borders(1),
Variables(X(:UMAP1), Y(:UMAP2), Color(:WARD UMAP CLUSTERS)),
Elements(Points(X, Y, Legend(27)))
);
Eval(EvalExpr(
Report(gb)[FrameBox(1)] << Add Graphics Script(
Text Size (14);
myaa = Expr(aa_colors);
ids = myaa << get keys;
For(i = 1, i <= N Items(ids), i++,
Fill Color ("white");
Transparency (0.85);
Circle({myaa[ids[i]]["X"], myaa[ids[i]]["Y"] + 0.25}, 0.5, "FILL");
Transparency(1);
Text Color(myaa[ids[i]]["Color"]);
Text(center justified, {myaa[ids[i]]["X"], myaa[ids[i]]["Y"]}, Char(ids[i]));
);
)
));