问题的难点在于每个facet中x axis的order都不相同,所以基本排除可以用一个scale_x_*()或者说一个图实现的可能。
作为替代,你可以分别绘制三个ggplots p1, p2, p3 后,通过grid.arrange( p1, p2, p3 )显示。
library(gridExtra)
tmp <- subset(data, items == "earprotector", c(names, quantity))
tmp$names <- factor(tmp$names, levels = tmp[order(tmp$quantity), "names"])
p1 <- ggplot(tmp, aes(x = names, y = quantity)) +
geom_bar(stat = 'identity')
tmp <- subset(data, items == "footprotector", c(names, quantity))
tmp$names <- factor(tmp$names, levels = tmp[order(tmp$quantity), "names"])
p2 <- ggplot(tmp, aes(x = names, y = quantity)) +
geom_bar(stat = 'identity')
tmp <- subset(data, items == "gloves", c(names, quantity))
tmp$names <- factor(tmp$names, levels = tmp[order(tmp$quantity), "names"])
p3 <- ggplot(tmp, aes(x = names, y = quantity)) +
geom_bar(stat = 'identity')
grid.arrange( p1, p2, p3 )