M1 から M11 までの係数の理論的な範囲があります。データM1からM3とM5には存在しません。M1 から M3 および M5 も x 軸に表示されるように、既存のものだけでなく、すべての M で ggplot2 barplot を実行するにはどうすればよいですか?
2 に答える
1
あなたの質問は再現できないので、スタンドアロンのコードで説明します
あなたが走るなら
library(ggplot2)
ggplot(mtcars, aes(factor(cyl))) + geom_bar()
あなたは得るでしょう
未使用のレベルを追加したい場合は、 と を使用できfactor(cyl)
ます。scale_x_discrete
limits
drop = F
例えば
ggplot(mtcars, aes(factor(cyl))) + geom_bar() +
scale_x_discrete(limits = c(1, 2, levels(factor(mtcars$cyl)), 10), drop=FALSE)
生産します
于 2014-05-01T10:20:27.120 に答える