如何根據數據范圍本身自動調整分佈中的 bin 寬度?當我使用分發平台時,默認情況下,bin 寬度總是很大,並且無助於更好地理解分發。 我必須處理的數據按馬級(兆、毫、單位等)變化,因此所有直方圖的固定箱不起作用。 另外,在我需要處理的實際情況下,我有數百個測試,因此逐一調整圖也是不可行的。 有沒有辦法使每個單獨圖的箱寬度由數據范圍確定? 例如,我想簡單地獲取範圍並將其分成 100 個等份或 50 等。因此,無論單位如何,所有繪圖的外觀都會有些統一,而無需單獨調整它們。 附件是 3 個圖示例,我希望默認情況下將 bin 寬度設置為數據范圍的 1/100。
謝謝!
數據探索和可視化回复:如何根據數據范圍本身自動調整分佈中的箱寬度?我能夠使用上面提供的部分代碼並使用 Eval/Parse 表達式來設置 bin。
謝謝。
dt = currentdatatable();
col = dt << get column names();
nc = N Items( col );
colList = {};
bin_width={};
For( i = 1, i <= nc, i++,
If(Contains (col[i],"::"),
Insert Into( colList, col[i] ))
);
For(i = 1, i <= N Items(colList), i++,
Insert Into(bin_width,0.0);
bin_width[i] = Col Max(Column(dt, colList[i])) - Col Min(Column(dt, colList[i]));
bin_width[i] = bin_width[i]/10;
);
theExpr = "dis = dt << Distribution(Stack( 1 ),
Continuous Distribution( column( column(dt,colList[1])), Set Bin Width(bin_width[1]), Label Row( Label Orientation( \!"Perpendicular\!" ) ))
";
For( i = 2, i < N Items( colList ), i++,
theExpr = theExpr || ", Continuous Distribution( column( column(dt, colList[" || Char( i ) || "])), Set Bin Width(bin_width[i]))"
);
theExpr = theExpr || ");";
Eval( Parse( theExpr ) );回复:如何根據數據范圍本身自動調整分佈中的箱寬度?謝謝@ron_horne和@jthi對於代碼片段。 我會嘗試一下。
回复:如何根據數據范圍本身自動調整分佈中的箱寬度?很可能是對我之前的代碼的改進,其中包含 Set Bin Width() @ron_horne 。
循環很可能可以通過更聰明的方式進行:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Students.jmp");
colList = {"height", "weight"};
dist = dt << Distribution(
Continuous Distribution(Column(:height)),
Continuous Distribution(Column(:weight))
);
wait(1);
For(i = 1, i <= N Items(colList), i++,
newInc = Col Max(Column(dt, colList[i])) - Col Min(Column(dt, colList[i]));
newInc = newInc/10;
dist[i] << Set Bin Width(newInc);
);回复:如何根據數據范圍本身自動調整分佈中的箱寬度?你好@布雷諾
作為開發的基礎怎麼樣:
Open( "$SAMPLE_DATA/Big Class.jmp" );
Distribution(
Continuous Distribution( Column( :height ), Set Bin Width( (colmax(:height)-colmin(:height))/50 ) ),
Continuous Distribution( Column( :weight ), Set Bin Width( (colmax(:weight)-colmin(:weight))/100 ) )
);
回复:如何根據數據范圍本身自動調整分佈中的箱寬度?你可以嘗試編寫腳本。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Students.jmp");
colList = {"height", "weight"};
dist = dt << Distribution(
Continuous Distribution(Column(:height)),
Continuous Distribution(Column(:weight))
);
wait(2);
rep_layer = Report(dist);
axisbox = rep_layer[axis box(1)];
For Each({val}, colList,
//some calculation for inc
newInc = Col Max(Column(dt, val)) - Col Min(Column(dt, val));
newInc = newInc/10;
cur_rep = rep_layer[OutlineBox(val)];
axisbox = cur_rep[axis box(1)];
axisbox << Inc(newInc);
);還有 Bin Span() 但我不確定在構建發行版後是否可以修改它。
回复:如何根據數據范圍本身自動調整分佈中的箱寬度?你好羅恩:
感謝您的建議。 不幸的是,它不喜歡大量的測試,我嘗試添加 ~ 30 個要繪製的測試,並給出錯誤“無法添加項目:列表已包含最大數量的項目”。
我希望有一個通用設置來調整 bin 寬度,因為大多數發行版都帶有寬條,因此這必須是一個關於如何確定它們有多寬的全局設置。
回复:如何根據數據范圍本身自動調整分佈中的箱寬度?你好@布雷諾,
從這裡開始:
https://community.jmp.com/t5/JMP-Add-Ins/2D-Histograms/ta-p/377945
如果有幫助請告訴我們。