Hi JMP Community,
Windows Pro 10 - JMP 17.2
I have some data projected on a 2D UMAP, and I would like to automatically insert the formatted (Color and Size) Cluster ID on top of the UMAP2 x UMAP1 Scatter Plot in Graph Builder. I managed to get the Cluster IDs by plotting them separately and merging them to the main FrameBox. Still, this is unsatisfactory because I cannot control the size and color of those Cluster ID labels.
I experimented with a Loop within an Add Graphics Script() command but could not make it work.
Here is the script I used to produce the plot above
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;
Thank you.
Best,
TS
Thierry R. Sornasse