我的資料框目前看起來像這樣
N = 61
MChange <- rnorm(N)
FChange <- rnorm(N)
Industry <- sample(N)
industry020406 <- data.frame(Industry, MChange, FChange)
使用以下代碼:
ggplot(industry020406, aes(reorder(Industry, MChange), MChange))
geom_col()
labs(x = "Industry",
y = "Tariff Cut (Percentage Points)")
theme(axis.text.x = element_text(angle = 90))
coord_flip()
我的條形圖如下所示:

由于很難識別重要的更改,有沒有辦法可以過濾掉函式之間-1和函式1內的MChange ggplot?
謝謝你。
uj5u.com熱心網友回復:
是的,只需像往常一樣過濾它,例如dplyr::filter
ggplot(dplyr::filter(industry020406, MChange < 1 & MChange > - 1),
aes(reorder(Industry, MChange), MChange))
geom_col()
labs(x = "Industry",
y= "Tariff Cut (Percentage Points)")
theme(axis.text.x = element_text(angle = 90))
coord_flip()

uj5u.com熱心網友回復:
您可以在以下位置進行過濾xlim():
x.lab <- with(industry020406, reorder(Industry, MChange)[MChange >= -1 & MChange <= 1])
ggplot(industry020406, aes(reorder(Industry, MChange), MChange))
geom_col()
coord_flip()
xlim(sort(x.lab))

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/462738.html
