在腳本內呼叫內建 JMP 選單函數大家好,
這裡是缺乏經驗的 JSL 腳本編寫者。 如果這是一個微不足道的問題,我深表歉意,但我想知道是否有一種方法可以從內部將特定旋轉角度的scatterplot 3D 命令插入到變數中(由用戶透過手動執行scatterplot 3D 生成的3D 圖形的旋轉預先確定) JSL 腳本。 例如,
sp = Scatterplot 3D(
Y( :age, :height, :weight ),
Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) )
);
,但想法是能夠做到這一點,而無需手動將旋轉值複製並貼上到程式碼中,因為我正在嘗試自動化一個過程,該過程需要來自已生成的散點圖的旋轉值作為輸入。 最終目標是擁有一個腳本,該腳本將預定的旋轉值作為輸入,並與 R 腳本(已編寫)交互,以從 3D 散點圖生成 2D 繪圖。這將使我能夠避免使用 Mac 剪貼簿的不便。
如有任何幫助,我們將不勝感激,謝謝。
自動化和腳本編寫品質和工藝工程回覆:在腳本中呼叫內建 JMP 選單函數我認為存在期望不匹配的情況。JMP 社群中討論群組的目的不是根據 JMP 使用者的請求提供完整的解決方案。我提供的腳本需要被視為解決該問題的一種方法的說明。供使用者擴展其最終解決方案的學習工具。
現在,為了解決最後一個條目的問題,您如何設想 JMP 用戶運行您想要的腳本?他們將如何選擇在散佈圖中使用哪些欄位?
如果計劃是讓用戶只運行 3D 散點圖,然後當他們將繪圖繪製到他們想要的點時,然後運行腳本以剝離腳本並獲取列和旋轉,這裡是一個片段JSL 找到散點圖窗口,然後從我的上一個條目中取得程式碼,建立一個csv 文件
Names Default To Here( 1 );
// Find the current report
curReport = Current Report();
// Check to see if the JMP current report is actually the Scatterplot 3D report
If( curReport[Outline Box( 1 )] << get title == "Scatterplot 3D",
theScript = Char( (xx[Outline Box( 1 )] << get scriptable object) << get script );
dt = Current Data Table();
,
// If not, find the window that is the 3D plot
i = 1;
While( Try( Window( i )[Outline Box( 1 )] << get title, "" ) != "Scatterplot 3D" & i < 100, i++ );
If( i < 100,
curReport = Window( i )[Outline Box( 1 )];
theScript = Char( (curReport[Outline Box( 1 )] << get scriptable object) << get script );
dt = Data Table( Trim( Word( 1, Window( i ) << get window title, "-" ) ) );
,
// If no Scatterplot 3D is jound, display an error
Dialog( "Error: No Scatterplot 3D was found" );
Throw();
);
);
// If the code makes it to here, strip off the script components needed
varsList = {};
Insert Into( varsList, Word( 2, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 4, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 6, Substr( theScript, Contains( theScript, "Y(" ) ), ":,)" ) );
rotationList = {};
Insert Into( rotationList, Word( 2, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 3, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 4, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
// Add the columns used and the rotations to a new data table
dtSub = dt << subset( columns( Eval( varsList ) ), selected rows( 0 ) );
dtSub << New Column( "_Vars_", character, set values( varsList ) );
dtSub << New Column( "_Rotation_", character, set values( rotationList ) );
dtSub << Save( "$TEMP/passvalues.csv" );
Close( dtSub, nosave );
回覆:在腳本中呼叫內建 JMP 選單函數感謝您提供的有用建議。 將嘗試將其整合到我的解決方案中。 這是有道理的。 我對此JSL 唯一關心的是,對於每個新資料集,我必須為我想要運行腳本的每個新資料集手動輸入3 個新列名稱(:age 等...),在我的例子中就會違背使這個過程自動化的目的。回覆:在腳本中呼叫內建 JMP 選單函數這個討論問題似乎與先前的討論相關或相同的問題從 3D 散點圖腳本中選擇旋轉和資料列
要回答這篇文章中的具體問題,您的腳本
sp = Scatterplot 3D(
Y( :age, :height, :weight ),
Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) )
);
運行時,產生輸出顯示對象,可以透過建立指向該對象的變數在 JSL 中存取該對象
spr = report( sp );
//or
spr = sp << report;
「spr」不包含散佈圖,而是指向輸出顯示樹中頂部物件的指針,該物件包含散佈圖以及與輸出顯示關聯的各種物件。
以下是我為上述討論問題編寫的腳本。在其中,它允許用戶運行 3D 散點圖,當散點圖關閉時,它會進入顯示樹並提取 JMP 腳本,如果運行該腳本,將重新生成 3D 散點圖,就像它在運行時一樣關門了。然後,腳本繼續提取 3 個軸的列和旋轉值,並將其放入分別稱為 varsList 和rotationList 的 2 個 JMP 清單中。然後,它將這些值作為新欄位新增回原始 JMP 資料表,然後將資料表儲存為 csv 檔案。
不知道 csv 檔案中需要什麼格式傳遞給 R,這只是對所需內容的猜測。
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
sp = Scatterplot 3D(
Y( :age, :height, :weight ),
Frame3D( Set Grab Handles( 0 ), Set Rotation( -54, 0, 38 ) )
);
sp << on close(
theScript = Char( (Report( sp ) << get scriptable object) << get script );
varsList = {};
Insert Into( varsList, Word( 2, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 4, Substr( theScript, Contains( theScript, "Y(" ) ), ":," ) );
Insert Into( varsList, Word( 6, Substr( theScript, Contains( theScript, "Y(" ) ), ":,)" ) );
rotationList = {};
Insert Into( rotationList, Word( 2, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 3, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
Insert Into( rotationList, Word( 4, Substr( theScript, Contains( theScript, "Rotation(" ) ), "()," ) );
dtSub = dt << subset( columns( Eval( varsList ) ), selected rows( 0 ) );
dtSub << New Column( "_Vars_", character, set values( varsList ) );
dtSub << New Column( "_Rotation_", character, set values( rotationList ) );
dtSub << Save( "$TEMP/passvalues.csv" );
close( dtSub, nosave );
);
// This line opens the csv back into JMP
//open("$TEMP/passvalues.csv");
作為 JMP 工作原理的註釋,無法將散佈圖放入變數中,然後將其傳遞給 R 或將其儲存為 .csv 檔案。但是,可以在將影像儲存到影像檔案時提取散點圖的影像,或將影像作為 blob 傳遞。我不太清楚你在找什麼。您可能想要研究 JMP 自動化,它允許您從 JMP 調用 R,並將所需資訊直接從 JMP 傳遞到 R。
請返回社區並提供您所需的更多具體信息,我們將盡力幫助您解決問題。
最後,我強烈建議您花時間閱讀《JMP/JSL 腳本指南》,該指南可以在「說明」下拉式選單下的 JMP 文件庫中找到。
回覆:在腳本中呼叫內建 JMP 選單函數作為後續,有沒有辦法將目前開啟的散佈圖插入變數中?