我想創建一個有兩層的繪圖網格;一個用于顯示密度,一個用于顯示離群值(通過geom_boxplot)。
我可以通過ggplot2的分層結構通過這段代碼來實作;
df %>%
ggplot(aes(x=value, color=variable))
facet_grid(~variable, scales = 'free')
geom_density(Aes(y=. .scaled.))
geom_boxplot(aes(x=value, fill=variable),
alpha=0.2,outlier。 color = 'black,outlier。 shape = 3,outlier.alpha = 1)
和它的欄位;
但是我希望boxplot中最靠近x軸的那一面是零。如果可視化會使它更容易解釋;
這是我的資料。
這是我的資料結構,由dput(df)
structure(list(variable=結構(c(1L。 1L, 1L,, 1L, 1L, 1L,
1L,/span> 1L。 1L, 1L, 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L, 1L,
1L,/span> 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L, 1L,
1L,/span> 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L。 1L, 1L。 2L, 2L。 2L, 2L, 2L,
2L,/span> 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L, 2L,
2L,/span> 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L。 2L, 2L, 2L,
2L,/span> 2L。 2L, 2L。 2L, 2L, 2L, 2L, 2L。 2L, 2L。 2L, 2L。 2L), 。 標簽 = c("hanehalki", 。
"gsyih")。 class = "factor")。 值 = c(2。 92, 3.05, 2. 82, 3.26,
2.86, 2.88, 4. 86, 4.92, 3.34, 3. 56, 3.81, 3.53, 3. 41, 2.68, 3.28,
3.23, 3.34, 2。 71, 2.98, 3.8, 2. 77, 4.09, 3, 3. 33, 3.06, 3.4,
3.05, 3.39, 2. 98, 3.1, 2.95, 5. 39, 3.13, 3.75, 3. 12, 4.88, 2.82,
2.99, 3.42, 2. 95, 3.41, 3.84, 3. 28, 2.83, 3.58, 4. 68, 2.76, 4.16,
2.89, 5.03, 41820. 1557045057, 29083. 9295704606, 31554.2128202566,
58956.7267073248, 41229.086549323, 38757. 9798583395, 23327.2168931588,
18708.4485132515, 43749.4317129513, 29105. 5044386941, 30235.1079173834, 30235.1079173834
30422.9283128681, 81228.0951424918, 55608. 1583883872, 34800.2529973319,
35914.5488124995, 33982.3005551545, 44302. 0289524954, 46529.3034031361, 46529.3034031361
31898.5500012572, 44088.1553908406, 37633. 0337337249, 47287.5078938497,
86798.4429060671, 60631.6357010175, 44210. 7976900847, 35742.82533139,36110.0565531365, 31586.3538734972, 33771. 6554831237, 30267.3076817561,
30192.1075499239, 37314.1420295662, 27322. 3774815836, 47001.4874496515,
16727.4244640104, 56462.8833985347, 43783. 0846449189, 40892.6265785975,
60553.5509558071, 32228.4494321578, 34105. 7208652381, 34644.9683658929,
38715.4350556293, 29966.7509482073, 23645. 372107655, 42288.6478926083,
22454.28959872,/span> 37888.643411857,/span> 26591. 7884353541)),行。 names = c(NA,)
-100L)。 class = c("data. table", "data.frame"))
預先感謝您的幫助。
uj5u.com熱心網友回復:
這樣做有效果嗎?(你可以用這個輕松地修改y的位置:)
df %>%
ggplot(aes(x=value, color=variable))
facet_grid(~variable, scales = 'free')
geom_density(Aes(y=. .scaled.))
geom_boxplot(aes(x=value, fill=variable, y= 0. 37),
alpha=0.2,outlier。 color = 'black,outlier。 shape = 3,outlier.alpha = 1)
輸出:
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/318961.html
標籤:
下一篇:ApacheNutchIndexerPlugintoManticoreSearch例外:java.lang.NoClassDefFoundError:com/manticoresearch/clien



