大家好,
我正在嘗試為表格摘要的每個元素繪製帶有參考線的圖表(腳本,JMP 13)(每個名稱+成績的分數與嘗試次數的圖表,然後在x軸上添加分數的25和75百分位的參考線) 。 如有任何評論,將不勝感激
| 姓名 | 年級 | 分數 | # 嘗試 |
| 姓名1 | A | 80 | 2 |
| 姓名1 | A | 82 | 3 |
| 姓名1 | 乙 | 98 | 3 |
| 姓名1 | C | 86 | 2 |
| 姓名2 | A | 88 | 3 |
| 姓名3 | A | 90 | 2 |
| 姓名3 | A | 88 | 1 |
| 姓名3 | A | 94 | 3 |
| 姓名4 | 乙 | 96 | 2 |
| 姓名4 | 乙 | 82 | 4 |
| 姓名4 | A | 100 | 1 |
| 姓名4 | C | 92 | 2 |
| 姓名5 | A | 84 | 3 |
你好@旋轉起來,
我想我明白你想要什麼。 但是,我也有點困惑:你是想總結還是只是繪製 9 個獨立的雙變量圖?
使用原始數據表,如果進行二元擬合,則可以輕鬆創建所有 9 個圖表,例如:
Bivariate(
Y( :Score ), X( :Name( "# try" ) ),
By( :Name, :Grade )
);
這將生成您在上一篇文章中著色的九張圖表。
然後,您可能需要做的是使用 For 循環來生成分位數線(或陰影區域)。
第一個圖的腳本類似於:
Bivariate(
Y( :Score ),
X( :Name( "# try" ) ),
Where( :Name == "name1" & :Grade == "A" ), // this would be selecting
SendToReport(
Dispatch(
{},
"2",
ScaleBox,
{Min( 75 ), Max( 100 ), Inc( 5 ), Minor Ticks( 1 ), // this sets the appearance of the y-axis
Add Ref Line( 83, "Solid", "Blue", "25th quantile", 1 ),
Add Ref Line( 95, "Solid", "Blue", "75th quantile", 1 )}
)
)
);事實上,如果您設置一個名稱列表 NameList={"Name1", "Name2"...},或者從列元素中提取它,那麼您可以通過放入 For 循環來獲得一個非常短的腳本,只需我們引用 NameList[i] 元素。 對於Where(:Name==NameList[i] & Grade == GradeList[i]) 也是如此。
另一種選擇是檢查上麵包含的第一個腳本的輸出的樹結構,然後為 9 個圖表的每個 y 軸引用 AxisBox(i)。 y 軸都是奇數,因此如果您執行 For 循環,則必須執行 i++,以便它在循環中從 1 迭代到 3 到 5,依此類推。
鏈接中有一些非常好的東西@Craige_Hales假如。
對於您的具體問題,我認為您肯定需要進行一些循環。 或者,您也可以手動完成整個過程一次,然後將腳本保存到數據表(可能作為一個組),然後您可以復制/粘貼該腳本並在新的腳本窗口中另存為單獨的 JSL 文件。 如果您能夠弄清楚如何手動執行此操作,JMP 將為您編寫 JSL,而您所需要做的就是將其全部放入一個主 JSL 文件中,該文件會為您處理所有事宜。 唯一的問題是您是否決定更改名稱或列引用或類似的內容。 如果這樣做,那麼您將需要開始使用局部變量。
希望這可以幫助!,
DS
也許是這樣的
dtBigClass = Open( "$sample_data/big class.jmp" );
dtage = dtBigClass << Summary( Group( :age ) ); // makes a small table of unique ages
ages = dtage[0, 1]; // [12, 13, 14, 15, 16, 17]
Close( dtage, "nosave" ); // table no longer needed
grid = Lineup Box( N Col( 3 ), spacing( 20, 30 ) ); // Horz,Vert extra space between graphs in pixels
For( iAge = 1, iAge <= N Rows( ages ), iAge += 1, // for each age...
dtBigClass << selectwhere( age == ages[iAge] );
dtSubset = dtBigClass << subset( selectedrows( 1 ), linked( 1 ), "invisible" );
// the summary will be a single row with the requested information
dtSummary = dtSubset << Summary( Mean( :height ), Mean( :weight ), Std Dev( :height ), Std Dev( :weight ), Freq( "None" ), Weight( "None" ) );
// grab the values of interest in simpler variable names
heightMean = dtSummary:name( "Mean(height)" )[1]; // row one has the answers
heightStdDev = dtSummary:name( "Std Dev(height)" )[1];
weightMean = dtSummary:name( "Mean(weight)" )[1];
weightStdDev = dtSummary:name( "Std Dev(weight)" )[1];
Close( dtSummary, "nosave" ); // close the work table, no longer needed
// make a graph, attach to a borderbox so it does not open in a window...
bb = Border Box(
dtSubset << Graph Builder(
Size( 400, 300 ),
Show Control Panel( 0 ),
Show Legend( 0 ), // don't need a legend
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
// add ref lines. You can get a script like this GraphBuilder script by
// making a graph builder interactively, then using the red triangle->get script.
// below, the numbers in the script have been replaced with the variables above.
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( heightMean, "Dotted", "Red", "", 2 ), Add Ref Line( heightMean + heightStdDev, "Dotted", "Blue", "", 2 ),
Add Ref Line( heightMean - heightStdDev, "Dotted", "Blue", "", 2 ),
// force all axes to be the same...
Min( 48.2828947368421 ), Max( 75.8776488919668 ), Inc( 5 ), Minor Ticks( 1 )}
),
Dispatch(
{},
"weight",
ScaleBox,
{Add Ref Line( weightMean, "Dotted", "Red", "", 2 ), Add Ref Line( weightMean + weightStdDev, "Dotted", "Blue", "", 2 ),
Add Ref Line( weightMean - weightStdDev, "Dotted", "Blue", "", 2 ),
// force all axes to be the same...
Min( 55.2100840336134 ), Max( 188.127074359155 ), Inc( 20 ), Minor Ticks( 0 )}
),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 6 ), Transparency( 1 )} ), // make the markers bigger
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Age = " || Char( ages[iAge] ) )} ), // add the age= title
Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "" )} ) // suppress the Graph Builder title
)
)
);
grid << append( bb ); // add the graph to the grid
); // the iAge loop
dtBigClass << clearRowStates; // undo the final selection
New Window( "the report", V List Box( H Center Box( Text Box( "Big Report", <<SETFONTSIZE></SETFONTSIZE>
Reports grouped in a 3-wide gridReports grouped in a 3-wide grid報告分組在 3 寬網格中
謝謝@SDF1對於您的回复,很抱歉不太清楚。 在這裡我想再解釋一下:
首先,我嘗試在單獨的腳本窗口中編寫腳本,以便我可以獨立運行它,這是腳本的第一部分,我試圖在其中獲取摘要:
Names Default To Here( 1 );
dt = Current Data Table();
Summary = dt << Summary(
Group( :Name, :Grade ),
Median( :Score ),
// other statistics can be added here//
Link to Original Data Table( 0 )
);
輸出將如下所示:

現在,我真正想要的是 9 個圖表( Score vs # try)(每行一個(有 N 行數據點)),然後使用每組的統計數據添加到參考線(全部通過腳本編寫)。
在您的圖表示例中,看起來它適用於任何等級的 name1。
謝謝
你好@旋轉起來,
我不確定我完全理解你想要做什麼,但你可能很難完全編寫整個事情的腳本。 如果您將數據表保留一段時間或將其加載,您可能需要單獨進行分析,然後將它們保存到數據表中。
如果您確實想編寫整個過程的腳本,您仍然需要運行分析來確定 25/75 分位數等。
當你說你正在繪製“分數與#嘗試”的圖表時,你的意思是當你執行“通過x擬合y”時,分數是“y”而“#嘗試”是“x”?
另外,當您說表格摘要時,您的意思是在按名稱和成績分組時找到分數和#try 的平均值嗎? 或者,您的意思是您正在按名稱列出成績並查找分數和#try 值的平均值?
不過,你可以通過幾種方式做到這一點。 我把你的表格帶入 JMP,這就是我所做的(假設我和你的想法一樣):
按名稱製表(A、B、C 是 # 項),這有助於獲取方法,但如果需要,您可以單獨編寫腳本。

有了這個,我用幾種不同的方式繪製了它:二元擬合或直方圖(直方圖已經可以從箱線圖中輕鬆獲得四分位信息)。然後您可以通過正常方式添加參考線。


為了編寫所有這些腳本,請務必使用紅色熱按鈕訪問實際的 JSL 腳本以生成您想要的內容。 但同樣,如果您將腳本保存到數據表中,那麼每次打開數據表時,您都可以單擊綠色熱按鈕并快速重新運行它。
希望這可以幫助!,
DS