我想找到一種方法讓抖動保持在自己的箱線圖中,而不會延伸到相鄰的箱線圖中。
到目前為止,我看了這些答案:
如您所見,抖動服從時間點分布(T0、T1、T2、T3),但在診斷(Diagnose)時,它與其他框重疊。
這是我的資料的示例:
structure(list(Time = c("T0", "T0", "T0", "T0", "T0", "T0", "T0", "T0", "T0", "T1", "T1", "T1", "T1", "T1", "T1", "T1", "T1", "T2", "T2", "T2", "T2", "T2", "T2", "T2", "T2", "T2", "T3", "T3", "T3", "T3", "T3", "T3", "T3", "T3", "T3"), Diagnose = c("PDD", "PDD", "PDD", "PD-MCI", "PD-MCI", "PD-MCI", "PD", "PD", "PD", "PD", "PD", "PD-MCI", "PD-MCI", "PD-MCI", "PDD", "PDD", "PDD", "PD", "PD", "PD", "PD-MCI", "PD-MCI", "PD-MCI", "PDD", "PDD", "PDD", "PD", "PD", "PD", "PD-MCI", "PD-MCI", "PD-MCI", "PDD", "PDD", "PDD"), Values = c(13.47, 14.25, 15, 20, 19.57, 15, 15, 17.54, 18, 16.93, 11.42, 18, 15, 19.48, 15, 11, 15, 18.03, 11, 15, 17.85, 19, 15, 15, 17.85, 20, 15, 19, 14.11, 12, 18.31, 16, 17.36, 20, 12)), row.names = c(NA, -35L), class = c("tbl_df", "tbl", "data.frame" ))這是使用 position = position_jitter() 、 position=position_jitterdodge() 、 position_dodge、 position_jitterdodge(dodge.width= ) 等時的輸出……
如您所見,這包含了中央箱線圖中的所有抖動。謝謝!
uj5u.com熱心網友回復:
幾乎!你要找的是
geom_point(position = position_jitterdodge()). 您還可以調整寬度jitter.widthggplot(df, mapping= aes(x = Time, y = Values)) geom_boxplot(aes(color = Diagnose), outlier.shape = NA ) geom_point(aes(color= Diagnose, shape=Diagnose), alpha = 0.5, position = position_jitterdodge(jitter.width = 0.1))
uj5u.com熱心網友回復:
指定減淡寬度
geom_jitter(width = 0.05)或者
geom_point(position = position_jitter(width = 0.05))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/371927.html
