我有一系列包含兩種行類型的座標。資料分為三個欄位:Column1(x 座標)、Column2(y 座標)和類型。
在雙變量分析中繪製它們並在兩組坐標周圍繪製一個橢圓後,我想在每個組的中心添加一個標記,標記每組坐標的質心。標記最好與“類型”列確定的顏色相符。
我可以在圖表下方的統計數據中看到我需要的值,它是每個組的 Column1 的平均值和 Column2 的平均值,但我不知道如何使用彩色標記將它們添加到圖表中。對於下圖,我手動添加了兩個“+”作為文本,但當我需要多次嘗試多個組時,這變得很麻煩。

也許是這樣的
Seemed easier to find the markers on a black background.在黑色背景上似乎更容易找到標記。
// this is an imperfect solution; the added marker color and position is static and
// will not respond to changes. It also depends on the organization of the displayboxes
// in the report.
oldpref = getpreference(Continuous Color Theme( )); // remember the old color pref
setpreference(Continuous Color Theme( "Spectral" )); // set a more obvious color change
bc=open("$sample_data/big class.jmp");
// make a graph with density ellipses for each age
bv = bc<
<BIVARIATE>
="15", elname = elOutline << gettitle; // "Bivariate Normal Ellipse P=0.950 age==17" // that same ellipse name appears above, with a color swatch. get the color. query = Eval Insert( "//TextEditBox[text()[contains(.,'^elname^')]]" ); // the query is the label to the right of a popup and the color. // .. moves up to the parent; the CustomBox child holds the color customBoxColor = bv << xpath( query || "/../CustomBox" ); // extracting the color from the popupbox legend: write to svg (customboxcolor) << savepicture( "$temp/color.svg", "svg" ); // read the svg text svgblob = Load Text File( "$temp/color.svg", blob() ); // parse the svg text to a data table, just grab the color dt = Open( svgblob, invisible, // I uses the XML wizard to generate this code. XML Settings( Stack( 0 ), Row( "/svg/g/g/g" ), // SVG *is* XML Col( "/svg/g/g/g/@stroke", Column Name( "color" ), Fill( "Use Once" ), Type( "Character" ), Format( {"Best"} ), Modeling Type( "Continuous" ) ) ), XML Wizard( 0 ) ); // the data table's color column (and only row) is the color elColor = Substr( dt:color[1], 2 ); // "#8E95D5", drop the # close(dt,nosave); // don't leave the invisible table open // convert the hex to a JSL color elColor = rgbcolor(Hex To Number( Substr( elColor, 1, 2 ) ),Hex To Number( Substr( elColor, 3, 2 ) ),Hex To Number( Substr( elColor, 5, 2 ) )); , // else JMP 14 has no XML elColor = rgbcolor(1,1,1); // white, opposite of background color, black ); // next, get the coordinates of the mean // minimal validation we are looking at the right column... if( elOutline[NumberColBox(1)]<
<GETHEADING></GETHEADING>
</BIVARIATE>
Links:
xpath: <A href="https://community.jmp.com/t5/Discovery-Summit-2015/JMP-Discovery-2015-Mining-JMP-Reports-v10-pdf/m-p/22595#U22595" class="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa" target="_blank">JMP Discovery 2015 - 採礦 JMP 報告 - v10.pdf</A> and <A href="https://community.jmp.com/t5/Discussions/xPath-coding-help/m-p/326500/highlight/true#M57581" target="_blank">這個</A>
ellipse: <A href="https://community.jmp.com/t5/Uncharted/Ellipse/m-p/21242#U21242" class="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa" target="_blank">橢圓</A>
XML: <A href="https://community.jmp.com/t5/Uncharted/Open-an-RSS-Feed-in-JMP/m-p/239296#U239296" class="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa" target="_blank">在 JMP 中開啟 RSS 來源</A> , <A href="https://community.jmp.com/t5/Uncharted/Contour-Plot-Areas/m-p/294516#U294516" class="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa" target="_blank">等高線圖區域</A> , <A href="https://community.jmp.com/t5/Uncharted/Currency-Exchange-Rates/m-p/240876#U240876" class="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa" target="_blank">貨幣匯率</A> , <A href="https://community.jmp.com/t5/Uncharted/SQL-for-Cord-Cutters/m-p/238656#U238656" class="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa" target="_blank">剪線族的 SQL</A>
<BR />
在我看來,它看起來像這樣:
Marker Size( 6 );
Marker(
1,
{Col Mean( :Column 1, :Type == "Type1" ),
Col Mean( :Column 2, :Type == "Type1" )}
);
Marker(
1,
{Col Mean( :Column 1, :Type == "Type2" ),
Col Mean( :Column 2, :Type == "Type2" )}
);
然而該解決方案仍然需要每組添加一個標記。
有什麼方法可以新增「類型」列中包含的所有群組的所有標記嗎?
如何繼續使用分析中使用的相同顏色主題?
然而,這只是滿足我需要的一個簡單例子。通常我會有數十個需要添加到視覺化中的質心。在我的實際分析中,由於我需要繪製質心的可能類別數量太多,它很快就變得痛苦起來。
也許有一種方法可以添加這樣的座標,而無需手動向表中添加行。
有沒有辦法繪製類型分析計算出的平均值,避免手動繪圖?
或者甚至在 Graph Builder 中也沒關係,只要避免手動新增行(標記)。
只需在資料表中新增質心的座標和類型作為兩個新行。將其行狀態變更為排除、紅色或藍色以及「+」標記。