可能是用戶錯誤,但我一生都找不到它。嘗試使用“scale_x_discrete(limits=(...)”函式重新排列箱線圖中的因子順序。這樣做會導致以下警告訊息“警告訊息:洗掉了包含缺失值的 103 行( stat_boxplot”。一個分組丟失的情節是箱線圖。我很困惑,因為這對于其他因素的幾乎相同的情節來說效果很好,如果我不嘗試重新排列和運行它,情節是完全正常的照原樣.我可以告訴基礎資料框沒有任何問題(例如,沒有缺失值或 NA)。關于這里可能出現的問題有什么想法嗎?
謝謝!
箱線圖預發行示例:
maxn_topo_plot<- ggplot(wide.df2, aes(x=topo, y=sum_maxn))
geom_boxplot(show.legend = FALSE) theme_pubclean(base_size = 20) xlab("Island Geomorpholgy") ylab("Shark MaxN")
theme(axis.text.x = element_text(angle = 12))
maxn_topo_plot
有問題的代碼:
maxn_topo_plot<- ggplot(wide.df2, aes(x=topo, y=sum_maxn))
geom_boxplot(show.legend = FALSE) theme_pubclean(base_size = 20) xlab("Island Geomorpholgy") ylab("Shark MaxN")
scale_x_discrete(limits=c("open atoll","closed atoll","near atoll", "high barrier", "high rocky", "high fringing"))
theme(axis.text.x = element_text(angle = 12))
maxn_topo_plot
作業得很好的代碼:
max_isl_group<- ggplot(wide.df2, aes(x=isl_grp, y=sum_maxn))
geom_boxplot(show.legend = FALSE) theme_pubclean(base_size = 20) xlab("Island Group") ylab("Shark MaxN")
scale_x_discrete(limits=c("west tuamotu","east tuamotu","windward", "leeward", "marquesas", "australes"))
theme(axis.text.x = element_text(angle = 20))
max_isl_group
uj5u.com熱心網友回復:
我不知道你的代碼到底發生了什么
但是,如果您想要其他方式在沒有此訊息的情況下重新排序 x 軸,則為:
maxn_topo_plot<- ggplot(wide.df2, aes(x= factor(topo,
levels = c("open atoll",
"closed atoll",
"near atoll",
"high barrier",
"high rocky",
"high fringing")), y=sum_maxn))
geom_boxplot(show.legend = FALSE)
xlab("Island Geomorpholgy")
ylab("Shark MaxN")
theme_pubclean(base_size = 20)
theme(axis.text.x = element_text(angle = 12))
uj5u.com熱心網友回復:
在我的一個“高邊緣”因素中,這是一個流氓空間,這是根本問題。劉海頭放在桌子上。好幾個小時。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/476663.html
上一篇:我可以根據顏色選擇填充嗎?