WINDOWS 10 > JMP 17.2 > 图形生成器 > 散点图 > 动态聚类注释大家好,JMP 社区,
Windows 专业版 10-JMP 17.2
我有一些数据投影在 2D UMAP 上,我想在 Graph Builder 中自动将格式化的(颜色和大小)Cluster ID 插入到 UMAP2 x UMAP1 散点图的顶部。我设法通过单独绘制它们并将它们合并到主 FrameBox 来获取 Cluster ID。然而,这并不令人满意,因为我无法控制这些 Cluster ID 标签的大小和颜色。
我尝试在“添加图形脚本()”命令中使用循环,但无法使其工作。

这是我用来制作上述情节的脚本
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() 从“事物”的值颜色列表中获取项目。我还会在图形脚本内部评估图形脚本外部的变量,以避免变量丢失时出现各种烦人的问题。
我最有可能使用关联数组来收集 ID、颜色、x 和 y 坐标。这样做的一个问题可能是汇总和关联数组可能具有不同的顺序,必须考虑到这一点(我在这里没有这样做)。
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]));
);
)
));