JSL 能否用於自動繪製圖表並添加參考線等你好,
我定期繪製分佈圖。有時我只獲得幾列數據,有時則更多。
產生各個圖表後,我需要調整它們各自的最小/最大 Y 軸以提高可讀性,然後添加幾條參考線(基本上是 USL 和 LSL 線)。過了一段時間,就變得乏味了,尤其是有很多列資料。
我想看看是否有任何方法可以自動化此過程,因為該過程本身相對簡單且重複。 我認為 JSL 腳本可以成為這裡的解決方案(我對腳本非常陌生)。
這就是我希望腳本執行的操作:
1. 每列資料由5個資料點組成,第一行和第二行分別包含USL和LSL
2. 該腳本應讀取所有資料列
3. 繪製所有資料的單獨分佈圖
4.加上USL和LSL參考線(這裡可以設定線的粗細和顏色嗎?)
5.然後將Y軸的Min改為LSL-0.003,將Y軸的Max改為USL為USL+0.003
JSL可以做到以上嗎?
謝謝你!
自動化和腳本編寫回覆:JSL 能否用於自動繪製圖表並添加參考線等簡短回答:JSL 可以做到這一點。
回覆:JSL 能否用於自動繪製圖表並添加參考線等- 歡迎來到社區
- 是的,JMP 腳本可以輕鬆執行您概述的任務。
- JMP 將自動在每個圖表上顯示您的 USL 和 LSL 值。但是,您描述的資料結構不是 JMP 的正常結構。將 JSL 新增至腳本中以取得 USL 和 LSL 資料並將其移至每列的規格限制列屬性中,然後刪除資料的前 2 行是一件相當簡單的事情。
- 您的資料描述似乎顯示每列資料只有 3 個資料點。(5 個資料點減去 LSL 和 USL 行)並從中繪製分佈圖。使用 JMP 術語,分佈圖是直方圖顯示。這是您指定為您需要的圖表嗎?如果是這樣,如何從 3 個資料點建立此圖表。
- 更改軸的最小值和最大值非常容易,並且可以添加到腳本中。
- 我對您在最初條目中所描述內容的解釋可能是完全錯誤的。如果您可以提供您正在使用的資料範例以及您需要顯示的圖表的插圖,那就太好了。
- 我建議您花時間瀏覽 JMP 中「說明」下拉式選單下的「發現 JMP」文件。
回覆:JSL 能否用於自動繪製圖表並添加參考線等感謝您的回覆。
對於第四部分,我很抱歉我沒有很好地解釋自己。 需要明確的是,每列有 7 行資料。 第一行是 LSL,第二行是 USL。 第 3 行到第 7 行是實際資料。
對於第 6 部分,以下是我的範例資料和結果圖表:


對於本範例中的圖表,也繪製了第一行和第二行數據,但我不希望這樣做。 它們分別是 LSL 和 USL。 我通常所做的是不將 LSL 和 USL 包含在資料中。
回覆:JSL 能否用於自動繪製圖表並添加參考線等這是一個範例腳本,可以產生您想要的內容

Names Default To Here( 1 );
// Create the data table
// dt = open( "<PATH to="" the="" file="" that="" has="" the="" data="https://community.jmp.com/">" );
// Here is the sample data table you provided
dt = New Table( "Example",
Add Rows( 7 ),
New Column( "Data1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [9.5, 10.5, 10, 10.2, 9.7, 9.6, 10.4] )
),
New Column( "Data2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [4.5, 5.5, 5, 5.1, 5.2, 4.9, 4.7] )
)
);
// Ge all of the numeric column's names
colNameList = dt << get column names( string, continuous );
//Take the data from rows 1 & 2 and create the Spec Limints column property
For Each( {col}, colNameList,
Eval(
Substitute(
Expr(
Column( dt, col ) << set property(
"Spec Limits",
{LSL( _LSL_ ), USL( _USL_ ), Show Limits( 1 )}
)
),
Expr( _LSL_ ), As Column( dt, col )[1],
Expr( _USL_ ), As Column( dt, col )[2]
)
)
);
// Exclude and Hide row 1 & 2 to eliminate them from Distributions
dt << Select rows( {1,2} );
dt << hide and exclude;
// Run the Distribution Platform, having the Spec Limits as
// Column Properties, will insure the proper Min and Max for
// the Y axis
dt << Distribution( column( eval(colNameList) ));</PATH>回覆:JSL 能否用於自動繪製圖表並添加參考線等哦哇.. 我當然沒想到你會寫劇本——謝謝!
我看到腳本的前部分是關於創建我之前提供的範例資料表。 如何修改它以便我可以要求腳本指向我選擇的現有資料表(我想這是 .jmp 檔案)然後運行?
回覆:JSL 能否用於自動繪製圖表並添加參考線等打開表:腳本編寫指南 > 資料表 > 資料表入門(使用打開() )
從使用者選擇中取得路徑選擇文件()
回覆:JSL 能否用於自動繪製圖表並添加參考線等我的想法是我必須合併您在我的其他線程中幫助回答的另一組程式碼:
If( Is Missing( fn ),
throw(),
// Else Open the selected file
Open( fn )
);
我想打開文件後,我需要將其作為數據表加載? 這意味著使用 dt 語法?
回覆:JSL 能否用於自動繪製圖表並添加參考線等您使用 Open() 開啟資料表, open 然後傳回對已開啟的資料表的參考(如果成功開啟檔案),然後將其儲存到 dt 變量
dt = Open("myfile.jmp");回覆:JSL 能否用於自動繪製圖表並添加參考線等我修改了一位貢獻者之前共享的腳本(謝謝),以便用戶可以選擇要開啟的資料檔案(.jmp)檔案:
Names Default To Here( 1 );
// Open a dialog to choose a .jmp file to open
// Get the filename of the .jmp file to open
dt = Pick File("Select a .jmp file to open", "", {"JMP Files|jmp;jsl;jrn", "All Files|*"}, 1, 0, "");
// If the user did not select a file, exit the script
If( Is Missing( dt ),
Throw(),
// Else Open the selected file
Open( dt )
);
// Get all of the numeric column's names
colNameList = dt << get column names( string, continuous );
// Take the data from rows 1 & 2 and create the Spec Limits column property
For Each( {col}, colNameList,
Eval(
Substitute(
Expr(
Column( dt, col ) << set property(
"Spec Limits",
{LSL( _LSL_ ), USL( _USL_ ), Show Limits( 1 )}
)
),
Expr( _LSL_ ), As Column( dt, col )[1],
Expr( _USL_ ), As Column( dt, col )[2]
)
)
);
// Exclude and Hide row 1 & 2 to eliminate them from Distributions
dt << Select rows( {1,2} );
dt << hide and exclude;
// Run the Distribution Platform
dt << Distribution( column( eval(colNameList) ));運行腳本時,我遇到了以下錯誤:
Send 在存取或評估 'Send' 時期望可編寫腳本的對象,dt << /*###*/取得列名(字串,連續)/*###*/
dt << 取得列名稱似乎有問題?
回覆:JSL 能否用於自動繪製圖表並添加參考線等您將 dt 作為檔案路徑,因此它是一個字串。您需要讓它引用新開啟的文件,如下所示。注意 Open() 語句
Names Default To Here( 1 );
// Open a dialog to choose a .jmp file to open
// Get the filename of the .jmp file to open
dt = Pick File("Select a .jmp file to open", "", {"JMP Files|jmp;jsl;jrn", "All Files|*"}, 1, 0, "");
// If the user did not select a file, exit the script
If( Is Missing( dt ),
Throw(),
// Else Open the selected file
dt = Open( dt )
);
// Get all of the numeric column's names
colNameList = dt << get column names( string, continuous );
// Take the data from rows 1 & 2 and create the Spec Limits column property
For Each( {col}, colNameList,
Eval(
Substitute(
Expr(
Column( dt, col ) << set property(
"Spec Limits",
{LSL( _LSL_ ), USL( _USL_ ), Show Limits( 1 )}
)
),
Expr( _LSL_ ), As Column( dt, col )[1],
Expr( _USL_ ), As Column( dt, col )[2]
)
)
);
// Exclude and Hide row 1 & 2 to eliminate them from Distributions
dt << Select rows( {1,2} );
dt << hide and exclude;
// Run the Distribution Platform
dt << Distribution( column( eval(colNameList) ));回覆:JSL 能否用於自動繪製圖表並添加參考線等轉移到具有更相關標題的新線程。
回覆:JSL 能否用於自動繪製圖表並添加參考線等這段程式碼更乾淨一些:
// Get the filename of the .jmp file to open
filename = Pick File("Select a .jmp file to open", "", {"JMP Files|jmp;jsl;jrn", "All Files|*"}, 1, 0, "");
// If the user did not select a file, exit the script
If( Is Missing( filename ),
Throw(),
// Else Open the selected file
dt = Open( filename )
);